An ECU flashing program dynamic generation method and device

By breaking down the ECU flashing program into multiple functional segments and generating the ECU flashing program based on configuration parameters, the problem of insufficient flexibility and efficiency in existing ECU flashing solutions is solved, thereby improving both flexibility and efficiency.

CN122633211APending Publication Date: 2026-08-25WUHAN JIANGXIA CHUNENG AUTOMOBILE TECHNOLOGY R&D CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610808662.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-05
Publication Date
2026-08-25

AI Technical Summary

Technical Problem

Existing ECU flashing solutions lack flexibility and efficiency, resulting in rigid flashing processes, fixed security access policies, high coupling of business logic, and long update cycles.

Method used

The ECU flashing program is broken down into multiple functional segments. The source code is obtained from the local embedded database through the vehicle model code and ECU logical address. The ECU flashing program is generated by filtering, sorting and splicing according to the configuration parameters. It supports flexible combination and compilation of functional segments.

Benefits of technology

It improves the flexibility and efficiency of ECU flashing, avoids cumbersome linear processes, and enables flexible combination and efficient generation of functional segments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122633211A_ABST
    Figure CN122633211A_ABST
Patent Text Reader

Abstract

The application relates to an ECU (Electronic Control Unit) flashing program dynamic generation method and device, and belongs to the technical field of ECU software flashing, wherein the ECU flashing program dynamic generation method comprises the following steps: obtaining the source code of a plurality of function segments corresponding to a vehicle model code and an ECU (Electronic Control Unit) logical address from a local embedded database based on the vehicle model code and the ECU logical address; obtaining ECU flashing program configuration parameters, screening the source code of a plurality of target function segments from the source code of the plurality of function segments corresponding to the vehicle model code and the ECU logical address based on the ECU flashing program configuration parameters; sorting the source code of the plurality of target function segments based on the ECU flashing program configuration parameters, splicing the source code of the plurality of target function segments after the sorting, generating ECU flashing program source code, and compiling the ECU flashing program source code to generate an ECU flashing program. The application effectively improves the flexibility and efficiency of ECU flashing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of ECU software flashing technology, and in particular to a method and apparatus for dynamically generating ECU flashing programs. Background Technology

[0002] In the field of automotive aftermarket diagnostics, software rewriting of the Electronic Control Unit (ECU) is one of the core functions of a diagnostic tool. In traditional diagnostic tools, the ECU rewriting logic is usually implemented using hard coding, meaning that the rewriting process, data processing logic, and security access algorithms are directly embedded in the program code of the diagnostic tool's client application.

[0003] In existing technologies, when it is necessary to add support for new vehicle models, update the flashing process, fix flashing logic defects, or adapt to new ECU software versions, a linear process of "requirement proposal - software development - version compilation - system testing - version release - client update" must be followed. This approach has the following technical problems: rigid flashing process; fixed security access policies; high coupling of business logic; and long update cycles. This results in a lack of flexibility and efficiency in current ECU flashing.

[0004] Therefore, improving the flexibility and efficiency of ECU flashing has become a pressing technical problem that needs to be solved. Summary of the Invention

[0005] In view of this, it is necessary to provide a method and apparatus for dynamically generating ECU flashing programs to solve the problem of insufficient flexibility and efficiency of existing ECU flashing solutions.

[0006] To address the aforementioned problems, in a first aspect, the present invention provides a method for dynamically generating ECU flashing programs, comprising: Based on the vehicle model code and ECU logical address, the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address is obtained from the local embedded database. The local embedded database stores the source code of multiple functional segments obtained by disassembling multiple ECU flashing programs. Obtain the ECU flashing program configuration parameters. Based on the ECU flashing program configuration parameters, select the source code of multiple target functional segments from the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address. The ECU flashing program configuration parameters contain the functional requirements of the ECU flashing program. Based on the ECU flashing program configuration parameters, the source code of multiple target function segments is sorted, and the source code of the sorted multiple target function segments is spliced ​​together to generate the ECU flashing program source code. The ECU flashing program source code is then compiled to generate the ECU flashing program.

[0007] In one possible implementation, the multiple functional segments obtained from the disassembly of the multiple ECU flashing programs include: Pre-verification segment, secure access segment, signature verification segment, erase segment, write segment, verification segment, reset segment, and post-processing segment.

[0008] In one possible implementation, the ECU flashing program configuration parameters include: Execution mode parameters, pre-verification parameters, secure access parameters, post-processing parameters, environment adaptation parameters, log debugging parameters, and test module parameters.

[0009] In one possible implementation, the step of selecting the source code of multiple target functional segments from the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address based on the ECU flashing program configuration parameters includes: Based on the pre-verification parameters in the ECU flashing program configuration parameters, determine whether the source code of multiple target functional segments contains the source code of the pre-verification segment; Based on the post-processing parameters in the ECU flashing program configuration parameters, determine whether the source code of multiple target functional segments contains the source code of verification segments, reset segments, and post-processing segments.

[0010] In one possible implementation, determining whether the source code of multiple target functional segments contains the source code of the pre-verification segment based on the pre-verification parameters in the ECU flashing program configuration parameters includes: Based on whether the pre-verification parameter in the ECU flashing program configuration parameters is empty, determine whether the source code of multiple target functional segments contains the source code of the pre-verification segment.

[0011] In one possible implementation, determining whether the source code of multiple target functional segments contains the source code of a verification segment, a reset segment, and a post-processing segment based on the post-processing parameters in the ECU flashing program configuration parameters includes: Based on the integrity verification parameter value in the post-processing parameters of the ECU flashing program configuration parameters, determine whether the source code of multiple target functional segments contains the source code of the verification segment; Based on the value of the automatic reset parameter in the post-processing parameters of the ECU flashing program configuration parameters, determine whether the source code of multiple target functional segments contains the source code of the reset segment; Based on the fault code clearing parameter value and configuration writing parameter value in the post-processing parameters of the ECU flashing program configuration parameters, it is determined whether the source code of multiple target functional segments contains the source code of the post-processing segment.

[0012] In one possible implementation, the sorting of the source code of multiple target functional segments based on ECU flashing program configuration parameters includes: Based on the secure access parameters in the ECU flashing program configuration parameters, the order of the source code between the secure access segment and the signature verification segment is determined.

[0013] In one possible implementation, the source code of multiple functional segments obtained by disassembling multiple ECU flashing programs stored in the local embedded database is provided by a cloud database, which stores the latest version of the source code of all functional segments.

[0014] On the other hand, the present invention also provides an ECU flashing program dynamic generation device, comprising: The acquisition module is used to obtain the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address from the local embedded database based on the vehicle model code and ECU logical address. The local embedded database stores the source code of multiple functional segments obtained by disassembling multiple ECU flashing programs. The filtering module is used to obtain the ECU flashing program configuration parameters. Based on the ECU flashing program configuration parameters, it filters out the source code of multiple target functional segments from the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address. The ECU flashing program configuration parameters contain the functional requirements of the ECU flashing program. The generation module is used to sort the source code of multiple target function segments based on the ECU flashing program configuration parameters, splice the source code of the sorted multiple target function segments to generate the ECU flashing program source code, and compile the ECU flashing program source code to generate the ECU flashing program.

[0015] Secondly, the present invention also provides an ECU flashing program generation device, including a data acquisition unit, a memory, and a processor, wherein, The data acquisition device is communicatively connected to the processor and is used to acquire the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address, as well as the ECU flashing program configuration parameters. The memory is used to store the source code of multiple functional segments corresponding to the program and vehicle model codes and ECU logical addresses; The processor, coupled to the memory, is used to execute the program stored in the memory to implement the steps in the ECU flashing program dynamic generation method described in any of the above implementations.

[0016] The beneficial effects of this invention are as follows: The ECU flashing program dynamic generation method and apparatus provided by this invention first obtains the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address from a local embedded database based on the vehicle model code and ECU logical address. By decomposing the ECU flashing program into the source code of multiple functional segments, the functional segments can be flexibly combined according to requirements, thereby improving the flexibility of ECU flashing. Next, the ECU flashing program configuration parameters containing the functional requirements of the ECU flashing program are obtained. Based on the ECU flashing program configuration parameters, the source code of multiple target functional segments is selected from the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address, and the source code of multiple target functional segments is sorted. The source code of multiple target functional segments is concatenated according to the sorted source code of multiple target functional segments to generate the ECU flashing program source code. Then, the ECU flashing program source code is compiled to generate the ECU flashing program. By sorting and concatenating the source code of multiple target functional segments to generate the ECU flashing program source code and then generating the ECU flashing program, the cumbersome linear process in the existing solution can be avoided, and the efficiency of ECU flashing can be improved. This invention effectively improves the flexibility and efficiency of ECU flashing. Attached Figure Description

[0017] Figure 1 A schematic flowchart of an embodiment of the ECU flashing program dynamic generation method provided by the present invention; Figure 2 A schematic diagram of an embodiment of the segmented source code writing system architecture provided by the present invention; Figure 3 A schematic diagram illustrating an embodiment of the client assembly and compilation process provided by this invention; Figure 4 A schematic diagram of an embodiment of the ECU flashing program dynamic generation device provided by the present invention; Figure 5 This is a schematic diagram of an embodiment of the ECU flashing program generation device provided by the present invention. Detailed Implementation

[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.

[0019] In the description of the embodiments of the present invention, unless otherwise stated, "multiple" means two or more. "And / or" describes the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.

[0020] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0021] In various specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user behavior data, user historical data, and user location information, user permission or consent is obtained first. Furthermore, the collection, use, and processing of this data comply with relevant laws, regulations, and standards. Additionally, when embodiments of this application require access to sensitive personal information of users, separate permission or consent from the user is obtained through pop-ups or redirects to confirmation pages. Only after obtaining the user's separate permission or consent is the necessary user-related data required for the proper functioning of these embodiments acquired.

[0022] This invention provides a method and apparatus for dynamically generating ECU flashing programs, which will be described below.

[0023] Figure 1 This is a schematic flowchart of an embodiment of the ECU flashing program dynamic generation method provided by the present invention, as shown below. Figure 1 As shown, the method for dynamically generating ECU flashing programs includes: S101. Based on the vehicle model code and ECU logical address, obtain the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address from the local embedded database. The local embedded database stores the source code of multiple functional segments obtained by disassembling multiple ECU flashing programs.

[0024] It should be noted that this invention can be applied to vehicle ECU flashing scenarios, especially scenarios requiring efficient vehicle ECU flashing.

[0025] When dynamically generating ECU flashing programs, the ECU flashing program generation device (such as a desktop or portable computer) first obtains the vehicle model code and ECU logical address. Then, based on the vehicle model code and ECU logical address, it retrieves the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address from a local embedded database. The local embedded database stores the source code of multiple functional segments obtained by decomposing multiple ECU flashing programs. By decomposing the ECU flashing program into the source code of multiple functional segments, the functional segments can be flexibly combined according to requirements, thereby improving the flexibility of ECU flashing.

[0026] S102. Obtain ECU flashing program configuration parameters. Based on the ECU flashing program configuration parameters, select the source code of multiple target functional segments from the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address. The ECU flashing program configuration parameters contain the functional requirements of the ECU flashing program.

[0027] It should be noted that after obtaining the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address, the ECU flashing program generation device can obtain the ECU flashing program configuration parameters. These parameters contain the functional requirements of the ECU flashing program and can be pre-configured or configured in real-time by technicians. Then, based on the ECU flashing program configuration parameters, the source code of multiple target functional segments can be selected from the source code of the multiple functional segments corresponding to the vehicle model code and ECU logical address.

[0028] S103. Based on the ECU flashing program configuration parameters, sort the source code of multiple target function segments, splice the source code of the sorted multiple target function segments to generate the ECU flashing program source code, and compile the ECU flashing program source code to generate the ECU flashing program.

[0029] It should be noted that: Finally, the source code of multiple target functional segments can be sorted according to the ECU flashing program configuration parameters. Then, the sorted source code of multiple target functional segments is concatenated to generate the ECU flashing program source code. This source code is then compiled to generate the ECU flashing program. By sorting and concatenating the source code of multiple target functional segments to generate the ECU flashing program source code and subsequently the ECU flashing program, the cumbersome linear process in existing solutions can be avoided, thus improving the efficiency of ECU flashing.

[0030] In summary, the ECU flashing program dynamic generation method provided by this invention first obtains the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address from a local embedded database based on the vehicle model code and ECU logical address. By decomposing the ECU flashing program into the source code of multiple functional segments, the functional segments can be flexibly combined according to requirements, thereby improving the flexibility of ECU flashing. Next, the ECU flashing program configuration parameters containing the functional requirements of the ECU flashing program are obtained. Based on the ECU flashing program configuration parameters, the source code of multiple target functional segments is selected from the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address, and the source code of multiple target functional segments is sorted. The source code of multiple target functional segments is concatenated to generate the ECU flashing program source code, and then the ECU flashing program source code is compiled to generate the ECU flashing program. By sorting and concatenating the source code of multiple target functional segments to generate the ECU flashing program source code and then generating the ECU flashing program, the cumbersome linear process in the existing solution can be avoided, and the efficiency of ECU flashing can be improved. This invention effectively improves the flexibility and efficiency of ECU flashing.

[0031] In some embodiments of the present invention, the multiple functional segments obtained by disassembling the multiple ECU flashing programs include: Pre-verification segment, secure access segment, signature verification segment, erase segment, write segment, verification segment, reset segment, and post-processing segment.

[0032] It should be noted that the multiple functional segments obtained from disassembling multiple ECU flashing programs can specifically include pre-verification segments (functions related to checking before flashing), secure access segments (functions related to ECU security authentication), signature verification segments (functions related to verifying flashing data signatures), erasure segments (functions related to erasing the ECU's specified storage area), writing segments (functions related to writing data to the ECU), verification segments (functions related to integrity verification), reset segments (functions related to ECU reset), and post-processing segments (functions related to DTC clearing and configuration writing).

[0033] In some embodiments of the present invention, the ECU flashing program configuration parameters include: Execution mode parameters, pre-verification parameters, secure access parameters, post-processing parameters, environment adaptation parameters, log debugging parameters, and test module parameters.

[0034] It should be noted that the ECU flashing program configuration parameters may include execution mode parameters (such as flashing model, number of retries in case of flashing failure, etc.), pre-verification parameters (such as the specific checks to be performed before flashing), security access parameters (such as the order of access and signature verification, security level, etc.), post-processing parameters (such as integrity verification options, automatic reset options, etc.), environment adaptation parameters (such as high voltage monitoring, low voltage protection, etc.), log debugging parameters (such as alarm reporting mode), and test module parameters (such as whether the stress test mode is started, the number of stress test cycles, the stress test cycle period, etc.).

[0035] In some embodiments of the present invention, the step of selecting the source code of multiple target functional segments from the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address based on the ECU flashing program configuration parameters includes: Based on the pre-verification parameters in the ECU flashing program configuration parameters, determine whether the source code of multiple target functional segments contains the source code of the pre-verification segment; Based on the post-processing parameters in the ECU flashing program configuration parameters, determine whether the source code of multiple target functional segments contains the source code of verification segments, reset segments, and post-processing segments.

[0036] It should be noted that when selecting the source code of multiple target functional segments from the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address based on the ECU flashing program configuration parameters, the source code of multiple target functional segments can be determined by the pre-verification parameters in the ECU flashing program configuration parameters to determine whether the source code of multiple target functional segments contains the source code of the pre-verification segment, and by the post-processing parameters in the ECU flashing program configuration parameters to determine whether the source code of multiple target functional segments contains the source code of the verification segment, the reset segment, and the post-processing segment.

[0037] In some embodiments of the present invention, determining whether the source code of multiple target functional segments contains the source code of the pre-verification segment based on the pre-verification parameters in the ECU flashing program configuration parameters includes: Based on whether the pre-verification parameter in the ECU flashing program configuration parameters is empty, determine whether the source code of multiple target functional segments contains the source code of the pre-verification segment.

[0038] It should be noted that when determining whether the source code of multiple target functional segments contains the source code of the pre-verification segment based on the pre-verification parameters in the CU flashing program configuration parameters, the source code of multiple target functional segments can be determined by whether the pre-verification parameters in the ECU flashing program configuration parameters are empty.

[0039] In some embodiments of the present invention, determining whether the source code of multiple target functional segments contains the source code of a verification segment, a reset segment, and a post-processing segment based on the post-processing parameters in the ECU flashing program configuration parameters includes: Based on the integrity verification parameter value in the post-processing parameters of the ECU flashing program configuration parameters, determine whether the source code of multiple target functional segments contains the source code of the verification segment; Based on the value of the automatic reset parameter in the post-processing parameters of the ECU flashing program configuration parameters, determine whether the source code of multiple target functional segments contains the source code of the reset segment; Based on the fault code clearing parameter value and configuration writing parameter value in the post-processing parameters of the ECU flashing program configuration parameters, it is determined whether the source code of multiple target functional segments contains the source code of the post-processing segment.

[0040] It should be noted that when determining whether the source code of multiple target functional segments contains the source code of verification segments, reset segments, and post-processing segments based on the post-processing parameters in the ECU flashing program configuration parameters, the source code of multiple target functional segments can be determined by the integrity verification parameter value in the post-processing parameters of the ECU flashing program configuration parameters; the source code of multiple target functional segments can be determined by the automatic reset parameter value in the post-processing parameters of the ECU flashing program configuration parameters; and the source code of multiple target functional segments can be determined by the fault code clearing parameter value and the configuration writing parameter value in the post-processing parameters of the ECU flashing program configuration parameters.

[0041] In some embodiments of the present invention, the sorting of the source code of multiple target functional segments based on ECU flashing program configuration parameters includes: Based on the secure access parameters in the ECU flashing program configuration parameters, the order of the source code between the secure access segment and the signature verification segment is determined.

[0042] It should be noted that when sorting the source code of multiple target function segments according to the ECU flashing program configuration parameters, the order between the source code of the security access segment and the signature verification segment can be determined according to the security access parameters in the ECU flashing program configuration parameters.

[0043] In some embodiments of the present invention, the source code of multiple functional segments obtained by disassembling multiple ECU flashing programs stored in the local embedded database is provided by a cloud database, which stores the latest version source code of all functional segments.

[0044] It should be noted that the source code of multiple functional segments obtained from the disassembly of multiple ECU flashing programs stored in the local embedded database can be provided by the cloud database. The cloud database stores the latest version of the source code of all functional segments, thereby ensuring the validity of the source code of the functional segments.

[0045] Combination Figure 2 The present invention provides a system that breaks down the ECU flashing program into independent functional segments, which are dynamically combined and compiled and executed in real time by technicians on the client side by selecting parameters. It comprises three core parts: 1. Cloud-based segmented source code library: Stores the source code of the disassembled independent functional segments, each segment has an independent version number.

[0046] 2. Client configuration module: Provides a configuration interface and records the configuration parameters selected by the technician.

[0047] 3. Client-side assembly engine: Filters fragments based on configuration parameters, adjusts their order, generates complete source code, and compiles it dynamically.

[0048] The dynamic generation process of the flashing program specifically includes the following steps: (a) Segmented source code design.

[0049] The ECU flashing program is broken down into the following functional segments, each stored as an independent Java source code file, with the following functions:

[0050] (ii) Definition of client configuration parameters.

[0051] The client interface records the following configuration parameters, all of which are stored in a local configuration file as key-value pairs: Execution mode parameters:

[0052] Pre-validation parameters:

[0053] Security access parameters:

[0054] Post-processing parameters:

[0055] Environment adaptation parameters:

[0056] Log debugging parameters:

[0057] Test module parameters:

[0058] (III) Client assembly and compilation.

[0059] Combination Figure 3 Here are the specific steps involved in the client assembly and compilation process: 1. Obtain the segmented source code.

[0060] The client retrieves the source code of all relevant segments from the local embedded database based on the currently selected vehicle model code and ECU logical address. The query criteria are the vehicle model and ECU address fields, and the returned results include a unique identifier, source code content, and version number for each segment.

[0061] 2. Read user configuration.

[0062] The client reads all configuration parameters saved by the technician from the local configuration file. The configuration file is stored in standard JSON format and contains all configuration items in the client configuration parameter section.

[0063] 3. Segment selection.

[0064] The client iterates through all fragments and decides whether to include a fragment in the final program based on configuration parameters: 1) If the pre-validation item array is empty, exclude the pre-validation segment; 2) If the integrity check result is false, then exclude the check segment; 3) If the "whether to perform automatic reset" result is false, then exclude the reset segment; 4) If both "clear fault codes" and "write configuration" are false, then exclude post-processing segments; 5) Secure access segments, erase segments, and write segments are always included.

[0065] 4. Adjust the order.

[0066] The client determines the execution order of the fragments based on configuration parameters: 1) If the signature verification order is "verify first, then access", then the signature verification segment will be placed before the secure access segment; 2) If the signature verification order is "access first, signature verification later", then the secure access segment will be placed before the signature verification segment; 3) Other segments are arranged in a fixed order: the pre-verification segment is at the beginning, followed by the security authentication group, then the erase segment, the write segment, and finally the verification segment, the reset segment, and the post-processing segment.

[0067] 5. Condition code generation.

[0068] The client generates corresponding conditional judgment logic based on each configuration parameter: 1) For the pre-verification item array, iterate through each item in the array and generate the corresponding verification logic. If the array contains version checks, generate version check code; if it contains voltage checks, generate voltage check code, and so on.

[0069] 2) Regarding whether to enable high-voltage safety mode, if the parameter is true, high-voltage monitoring logic will be generated; otherwise, it will not be generated.

[0070] 3) For security level parameters, generate corresponding authentication logic based on their values. A value of R&D level generates an R&D level authentication code, a value of factory level generates a factory level authentication code, and a value of after-sales level generates an after-sales level authentication code.

[0071] 6. Dynamic code assembly.

[0072] The client concatenates the filtered source code fragments in the adjusted order to generate a complete Java class source code. The generated class contains a constructor to receive user-configured parameters and an execution method to call the fragments in sequence.

[0073] The internal logic of the execution method is organized in the order determined in step 4. Each fragment has a corresponding condition judgment before it is called: for optional fragments, it is first judged whether the corresponding boolean value in the configuration parameter is true, and it is called only if it is true; for pre-validation fragments, a pre-validation item array is passed in when it is called, and the fragment executes the corresponding check item according to the array content.

[0074] 7. Dynamic compilation.

[0075] The client calls the Java compiler API to compile the source code generated in step 6 in memory. The compilation process does not produce any disk files; the compilation result is directly output to memory as bytecode.

[0076] 8. Class loading and instantiation.

[0077] After successful compilation, the client creates a custom class loader, loads the bytecode from memory into the current runtime environment, and creates an instance of the class. During instantiation, the user configuration parameters read in step 2 are passed in through the constructor.

[0078] 9. Execution and caching.

[0079] The client calls the instantiated execution method to begin flashing the ECU.

[0080] (iv) Cloud source code synchronization mechanism.

[0081] The cloud database stores the latest version of the source code for each segment, as well as the configuration parameter definitions supported by the segment. Upon startup, the client executes a synchronization process: the client reports a list of version numbers for all local segments to the cloud; the cloud compares these lists one by one, adding segments with local version numbers lower than those on the cloud's list to the update list; the cloud returns the update list, containing the source code of the segments that need updating and the new version numbers; the client downloads these segments and updates its local database.

[0082] After synchronization is complete, the client reads the configuration parameter definitions of all fragments and dynamically generates a configuration interface based on these definitions. Each optional configuration item on the interface originates from the parameter definition exposed by a specific fragment.

[0083] Compared with the prior art, the present invention has the following beneficial effects: Technicians select parameters on the interface to determine which segments to execute, in what order, and which conditional checks to enable. In high-voltage environments, enabling high-voltage safety mode automatically generates high-voltage monitoring logic; when the voltage exceeds the threshold, the writing process pauses and a notification is displayed. In low-voltage environments, enabling low-voltage protection mode automatically generates low-voltage protection logic; when the voltage falls below the threshold, a charging notification is displayed. The same set of pre-verification segments can generate different combinations of version checks, voltage checks, and temperature checks by varying the values ​​of the pre-verification item array. The same set of secure access segments can adapt to three security levels—R&D, factory, and after-sales—by varying the security level parameter values; each level uses different authentication keys and permissions. The signature verification order parameter controls the execution order of the signature verification and secure access segments. The security level parameter controls the authentication key level used by the secure access segment. The multi-level authentication parameter controls whether to add additional authentication steps on top of a single authentication. After these parameters are selected on the interface, the client automatically adjusts the corresponding logic branches during code generation. If a segment's source code is modified and a version number is added in the cloud, the client detects the version difference during synchronization and downloads the new version segment. The next time the technician performs the flashing process, the generated code will automatically include the latest logic, eliminating the need to update the client.

[0084] To better implement the ECU flashing program dynamic generation method in this embodiment of the invention, based on the ECU flashing program dynamic generation method, correspondingly, as follows: Figure 4 As shown, this embodiment of the invention also provides an ECU flashing program dynamic generation device, the ECU flashing program dynamic generation device 400 comprising: The acquisition module 401 is used to obtain the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address from the local embedded database based on the vehicle model code and ECU logical address. The local embedded database stores the source code of multiple functional segments obtained by disassembling multiple ECU flashing programs. The filtering module 402 is used to obtain the ECU flashing program configuration parameters. Based on the ECU flashing program configuration parameters, it filters out the source code of multiple target functional segments from the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address. The ECU flashing program configuration parameters contain the functional requirements of the ECU flashing program. The generation module 403 is used to sort the source code of multiple target function segments based on the ECU flashing program configuration parameters, splice the source code of the sorted multiple target function segments to generate the ECU flashing program source code, and compile the ECU flashing program source code to generate the ECU flashing program.

[0085] The ECU flashing program dynamic generation device 400 provided in the above embodiments can realize the technical solutions described in the above ECU flashing program dynamic generation method embodiments. The specific implementation principles of each module or unit can be found in the corresponding content in the above ECU flashing program dynamic generation method embodiments, and will not be repeated here.

[0086] like Figure 5 As shown, the present invention also provides an ECU flashing program generation device 500. The ECU flashing program generation device 500 includes a processor 501, a memory 502, a display 503, and a data acquisition device 504. Figure 5 Only some components of the ECU flashing program generation device 500 are shown; however, it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0087] In some embodiments, processor 501 may be a central processing unit (CPU), microprocessor, or other data processing chip, used to run program code stored in memory 502 or process data, such as the ECU flashing program dynamic generation method of the present invention.

[0088] In some embodiments, processor 501 may be a single server or a group of servers. The server group may be centralized or distributed. In some embodiments, processor 501 may be local or remote. In some embodiments, processor 501 may be implemented on a cloud platform. In one embodiment, the cloud platform may include a private cloud, public cloud, hybrid cloud, community cloud, distributed cloud, internal cloud, multi-cloud, etc., or any combination thereof.

[0089] In some embodiments, memory 502 may be an internal storage unit of the ECU flashing program generation device 500, such as a hard disk or memory of the ECU flashing program generation device 500. In other embodiments, memory 502 may also be an external storage device of the ECU flashing program generation device 500, such as a pluggable hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the ECU flashing program generation device 500.

[0090] Furthermore, the memory 502 may include both internal storage units of the ECU flashing program generation device 500 and external storage devices. The memory 502 is used to store the application software and various data installed by the ECU flashing program generation device 500.

[0091] In some embodiments, display 503 may be an LED display, a liquid crystal display, a touch-screen liquid crystal display, or an organic light-emitting diode (OLED) touchscreen. Display 503 is used to display information from the ECU flashing program generation device 500 and to display a visual user interface. Components 501-503 of the ECU flashing program generation device 500 communicate with each other via a system bus.

[0092] In some embodiments, the data acquisition device 504 may be a chip or circuit with data transmission and reception functions.

[0093] In one embodiment, when the processor 501 executes the ECU flashing program dynamically generated program in the memory 502, the following steps can be implemented: Based on the vehicle model code and ECU logical address, the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address is obtained from the local embedded database. The local embedded database stores the source code of multiple functional segments obtained by disassembling multiple ECU flashing programs. Obtain the ECU flashing program configuration parameters. Based on the ECU flashing program configuration parameters, select the source code of multiple target functional segments from the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address. The ECU flashing program configuration parameters contain the functional requirements of the ECU flashing program. Based on the ECU flashing program configuration parameters, the source code of multiple target function segments is sorted, and the source code of the sorted multiple target function segments is spliced ​​together to generate the ECU flashing program source code. The ECU flashing program source code is then compiled to generate the ECU flashing program.

[0094] It should be understood that when the processor 501 executes the ECU flashing program dynamically generated program in the memory 502, in addition to the functions mentioned above, it can also perform other functions, as can be found in the description of the corresponding method embodiments above.

[0095] Furthermore, this embodiment of the invention does not specifically limit the type of the ECU flashing program generation device 500 mentioned. The ECU flashing program generation device 500 can be a portable electronic device such as a mobile phone, tablet computer, personal digital assistant (PDA), wearable device, or laptop computer. Exemplary embodiments of portable electronic devices include, but are not limited to, portable electronic devices running iOS, Android, Microsoft, or other operating systems. The aforementioned portable electronic devices can also be other portable electronic devices, such as laptop computers with touch-sensitive surfaces (e.g., touch panels). It should also be understood that in some other embodiments of the invention, the ECU flashing program generation device 500 may not be a portable electronic device, but rather a desktop computer with a touch-sensitive surface (e.g., a touch panel).

[0096] The above provides a detailed description of the ECU flashing program dynamic generation method and apparatus provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for dynamically generating ECU flashing programs, characterized in that, include: Based on the vehicle model code and ECU logical address, the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address is obtained from the local embedded database. The local embedded database stores the source code of multiple functional segments obtained by disassembling multiple ECU flashing programs. Obtain the ECU flashing program configuration parameters. Based on the ECU flashing program configuration parameters, filter out the source code of multiple target functional segments from the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address. The ECU flashing program configuration parameters contain the functional requirements of the ECU flashing program. Based on the ECU flashing program configuration parameters, the source code of multiple target function segments is sorted, and the source code of the sorted target function segments is spliced ​​together to generate the ECU flashing program source code. The ECU flashing program source code is then compiled to generate the ECU flashing program.

2. The ECU flashing program dynamic generation method according to claim 1, characterized in that, The multiple functional segments obtained from the disassembly of the multiple ECU flashing programs include: Pre-verification segment, secure access segment, signature verification segment, erase segment, write segment, verification segment, reset segment, and post-processing segment.

3. The ECU flashing program dynamic generation method according to claim 2, characterized in that, The ECU flashing program configuration parameters include: Execution mode parameters, pre-verification parameters, secure access parameters, post-processing parameters, environment adaptation parameters, log debugging parameters, and test module parameters.

4. The ECU flashing program dynamic generation method according to claim 3, characterized in that, The method involves selecting the source code of multiple target functional segments from the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address based on the ECU flashing program configuration parameters. These segments include: Based on the pre-verification parameters in the ECU flashing program configuration parameters, determine whether the source code of multiple target functional segments contains the source code of the pre-verification segment; Based on the post-processing parameters in the ECU flashing program configuration parameters, determine whether the source code of multiple target functional segments contains the source code of verification segments, reset segments, and post-processing segments.

5. The ECU flashing program dynamic generation method according to claim 4, characterized in that, The determination of whether the source code of multiple target functional segments contains the source code of the pre-verification segment based on the pre-verification parameters in the ECU flashing program configuration parameters includes: Based on whether the pre-verification parameter in the ECU flashing program configuration parameters is empty, determine whether the source code of multiple target functional segments contains the source code of the pre-verification segment.

6. The ECU flashing program dynamic generation method according to claim 4, characterized in that, The determination of whether the source code of multiple target functional segments contains the source code of verification segments, reset segments, and post-processing segments based on the post-processing parameters in the ECU flashing program configuration parameters includes: Based on the integrity verification parameter value in the post-processing parameters of the ECU flashing program configuration parameters, determine whether the source code of multiple target functional segments contains the source code of the verification segment; Based on the value of the automatic reset parameter in the post-processing parameters of the ECU flashing program configuration parameters, determine whether the source code of multiple target functional segments contains the source code of the reset segment; Based on the fault code clearing parameter value and configuration writing parameter value in the post-processing parameters of the ECU flashing program configuration parameters, determine whether the source code of multiple target functional segments contains the source code of the post-processing segment.

7. The method for dynamically generating ECU flashing programs according to claim 3, characterized in that, The sorting of source code for multiple target functional segments based on ECU flashing program configuration parameters includes: Based on the secure access parameters in the ECU flashing program configuration parameters, the order of the source code between the secure access segment and the signature verification segment is determined.

8. The method for dynamically generating ECU flashing programs according to claim 1, characterized in that, The source code of multiple functional segments obtained from the disassembly of multiple ECU flashing programs stored in the local embedded database is provided by a cloud database, which stores the latest version of the source code of all functional segments.

9. A device for dynamically generating ECU flashing programs, characterized in that, include: The acquisition module is used to obtain the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address from the local embedded database based on the vehicle model code and ECU logical address. The local embedded database stores the source code of multiple functional segments obtained by disassembling multiple ECU flashing programs. The filtering module is used to obtain the ECU flashing program configuration parameters. Based on the ECU flashing program configuration parameters, it filters out the source code of multiple target functional segments from the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address. The ECU flashing program configuration parameters contain the functional requirements of the ECU flashing program. The generation module is used to sort the source code of multiple target function segments based on the ECU flashing program configuration parameters, splice the source code of the sorted multiple target function segments to generate the ECU flashing program source code, and compile the ECU flashing program source code to generate the ECU flashing program.

10. An ECU flashing program generation device, characterized in that, Includes a data acquisition unit, memory, and processor, among which, The data acquisition device is communicatively connected to the processor and is used to acquire the source code of multiple functional segments corresponding to the vehicle model code and ECU logical address, as well as the ECU flashing program configuration parameters. The memory is used to store the source code of multiple functional segments corresponding to the program and vehicle model codes and ECU logical addresses; The processor, coupled to the memory, is used to execute the program stored in the memory to implement the steps in the ECU flashing program dynamic generation method according to any one of claims 1 to 7.