Program flashing method and device, computer device and storage medium

By adopting a partitioned design of temporary storage area and shared module in ECU firmware flashing, and by using the application binary interface to bypass the function interface to achieve shared module updates, the problem of low efficiency in traditional ECU firmware flashing is solved, and flashing efficiency and storage resource utilization are improved.

CN123137696APending Publication Date: 2026-11-20SHENZHEN XIHUA TECHNOLOGY CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611262759.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-19
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

Traditional ECU firmware flashing methods are inefficient. As the amount of application data increases, the flashing time gradually increases, affecting the stable operation of the program.

Method used

The system employs a partitioned design that separates the temporary storage area from the shared module area in non-volatile memory. It replaces the full program update with updates to the shared module and bypasses the function interface by utilizing the application binary interface to achieve data residency and avoid program crashes.

Benefits of technology

Significantly reduces upgrade time and communication volume, saves storage resources, improves software architecture flexibility and maintainability, and avoids program crashes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123137696A_ABST
    Figure CN123137696A_ABST
Patent Text Reader

Abstract

The application relates to a program flashing method and device, computer equipment and a storage medium. The method is applied to a target chip, the nonvolatile memory of the target chip comprises a temporary storage area, and a plurality of shared module areas of a boot program and an application program, each of the shared module areas stores a shared module, the method comprises the following steps: in response to a flashing instruction, data is acquired and stored in the temporary storage area to obtain temporary storage data; the to-be-updated shared module corresponding to the temporary storage data and the non-updated shared module are determined, and the to-be-updated shared module is updated based on the temporary storage data to obtain an updated shared module; and based on the to-be-updated shared module and the plurality of non-updated shared modules, a post-flashing program is run; the pre-flashing program and the post-flashing program comprise at least part of the programs of the boot program and / or the application program before and after updating. By using the method, the stable operation of the program is not affected, and the program is efficiently flashed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of program flashing, and in particular to a program flashing method, apparatus, computer equipment, storage medium and computer program product. Background Technology

[0002] With the intelligent development of the automotive industry, ECU firmware upgrades have evolved from traditional after-sales repair methods into a more complex process. Automotive ECU firmware flashing is achieved based on the Unified Diagnostic Services (UDS) protocol.

[0003] In traditional technology, the bootloader (BTL) is responsible for performing the flashing process. It receives flashing instructions from the host computer and completes the erasure of the application's (APP) corresponding non-volatile memory and the writing of the new version image. However, as the amount of data in the application gradually increases, the time required for each flashing operation gradually increases, and the processing efficiency gradually decreases. Summary of the Invention

[0004] Therefore, it is necessary to provide a program flashing method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can efficiently flash programs without affecting their stable operation, in order to address the aforementioned technical problems.

[0005] In a first aspect, this application provides a program flashing method applied to a target chip, wherein the non-volatile memory of the target chip includes a temporary storage area and multiple shared module areas for the boot program and application programs, each of the shared module areas storing a shared module, and the method includes:

[0006] The program is generated and run based on multiple shared modules before flashing.

[0007] In response to the write command, data is acquired and stored in the temporary storage area to obtain temporary data; the shared module to be updated and the non-updated shared module corresponding to the temporary data are determined, and the shared module to be updated is updated based on the temporary data to obtain the updated shared module;

[0008] Based on the shared module to be updated and multiple non-updated shared modules, the flashing program is run; the pre-flashing program and the flashing program include at least a portion of the bootloader and / or the application program before and after the update.

[0009] In one embodiment, the step of generating and running the pre-flash program based on multiple shared modules includes:

[0010] According to the address range of multiple shared modules in the non-volatile memory, each shared module is instantiated and assigned a value to obtain the original instance of each shared module; based on the original instance of each shared module, the pre-flash program is run.

[0011] The process of running the flashed program based on the shared module to be updated and multiple non-updating shared modules includes:

[0012] According to the address range of the updated shared module, the updated shared module is assigned and instantiated to obtain an updated instance; based on the updated instance and multiple original instances of non-updated shared modules, the flashing program is run.

[0013] In one embodiment, the shared module includes module body data, the starting address of the shared module, and the address length;

[0014] The step of instantiating and assigning values ​​to each of the shared modules according to the address range of multiple shared modules in the non-volatile memory to obtain the original instances of each shared module includes:

[0015] Based on the starting address of each shared module, select data of the address length to obtain the original data of each module body data;

[0016] The original data of each module ontology is instantiated and assigned values ​​to obtain the original instances of each shared module;

[0017] The step of assigning and instantiating the updated shared module according to the address range of the updated shared module to obtain the updated instance includes:

[0018] The updated shared module is obtained by selecting data of the specified address length according to the starting address of the updated shared module.

[0019] The updated shared module's ontology data is instantiated and assigned values ​​to obtain the updated instance.

[0020] In one embodiment, the pre-flash program runs based on the original instance obtained by instantiating and assigning values ​​to the shared module to be updated;

[0021] The step of updating the shared module to be updated based on the temporary data to obtain the updated shared module includes:

[0022] Determine whether the program before flashing processes business data based on the original instance in the shared module to be updated;

[0023] If so, continue processing business data based on the original instance of the shared module to be updated;

[0024] If not, the temporary data is copied to the shared module area corresponding to the shared module to be updated, to obtain the updated shared module.

[0025] In one embodiment, copying the temporary data to the shared module area corresponding to the shared module to be updated, to obtain the updated shared module, includes:

[0026] Determine the program validity flag and the data to be wiped in the shared module to be updated;

[0027] While retaining the program's valid flag, the data to be wiped is deleted, and the temporary data is copied to the shared module area to obtain the updated shared module.

[0028] In one embodiment, the shared module includes verification data; updating the shared module to be updated based on the temporary data to obtain the updated shared module includes:

[0029] If the temporary data is deemed qualified based on the verification data in the temporary data, the temporary data is copied to the shared module area where the shared module to be updated is located, and the copied data is obtained.

[0030] If the copied data is deemed qualified based on the verification data in the copied data, an updated sharing module is obtained based on the qualified copied data.

[0031] In one embodiment, acquiring and storing data in the temporary storage area to obtain temporary data includes:

[0032] The system acquires data sent by the host computer, adjusts the address indicated by the acquired data sent by the host computer to the address of the temporary storage area, and stores the data sent by the host computer in the temporary storage area to obtain the temporary storage data.

[0033] The storage space occupied by the temporary storage area is not less than the storage space occupied by the largest shared module.

[0034] Secondly, this application also provides a program flashing device applied to a target chip, wherein the non-volatile memory of the target chip includes a temporary storage area and multiple shared module areas for the boot program and application programs, each of the shared module areas storing a shared module, and the device includes:

[0035] The runtime module is used to generate and run the pre-flash program based on multiple shared modules;

[0036] The update module is used to respond to the write command, acquire and store data in the temporary storage area to obtain temporary data; determine the shared module to be updated and the non-updated shared module corresponding to the temporary data, and update the shared module to be updated based on the temporary data to obtain the updated shared module.

[0037] The running module is used to run the flashed program based on the shared module to be updated and multiple non-updated shared modules; the pre-flash program and the post-flash program include at least a portion of the bootloader and / or the application program before and after the update.

[0038] Thirdly, this application also provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the program writing method in any of the above embodiments.

[0039] Fourthly, this application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the program writing method in any of the above embodiments.

[0040] Fifthly, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the program writing method in any of the above embodiments.

[0041] The aforementioned program flashing method, apparatus, computer equipment, and storage medium generate and run a pre-flashing program based on multiple shared modules; responding to a flashing command, they acquire and store data in a temporary storage area to obtain temporary data; they determine the shared modules to be updated and those not to be updated corresponding to the temporary data, and update the shared modules to be updated based on the temporary data to obtain updated shared modules; based on the shared modules to be updated and multiple non-updated shared modules, they run the post-flashing program; the pre-flashing program and the post-flashing program include at least a portion of the bootloader and / or application programs before and after the update. Therefore, both the bootloader and the application programs run based on shared modules, and updating the shared modules can replace updating the entire program, significantly shortening upgrade time and reducing communication overhead; moreover, since the temporary storage area and the shared module area are different regions of non-volatile memory; and the shared module area stores shared modules used to run the pre-flashing program and the post-flashing program, while the temporary storage area does not run programs but is only used for data updates of the shared modules, program crashes will not occur due to changes in the data in the temporary storage area. Attached Figure Description

[0042] Figure 1 This is a schematic diagram of the program distribution for a program execution method in one embodiment;

[0043] Figure 2This is a flowchart illustrating a program flashing method in one embodiment;

[0044] Figure 3 This is a flowchart illustrating the program's operation before and after program flashing in one embodiment.

[0045] Figure 4 This is a structural block diagram of a program writing device in one embodiment;

[0046] Figure 5 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0047] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0048] The program flashing method provided in this application embodiment can be applied to, for example, Figure 1 The diagram shows the distribution of non-volatile memory (NVM). The storage areas of this NVM include a bootloader main area 101, an application main area 102, and a temporary storage area 103, all written into the chip, as well as various shared module areas. Multiple shared module areas may be included; for example, different shared module areas 104 and 105 may be included, and so on. The bootloader main area 101 and application main area 102 are independently used programs, and can be accessed by the program. The temporary storage area 103 is used to acquire and temporarily store corresponding temporary data to update the shared module areas. The shared modules cooperate to implement their respective functions.

[0049] In one embodiment, such as Figure 2 As shown, a program flashing method is provided, applied to a target chip. The non-volatile memory of the target chip includes a temporary storage area and multiple shared module areas for the boot program and application programs. Each shared module area stores a shared module. The method includes the following steps:

[0050] Step 202: Generate and run the pre-flash program based on multiple shared modules.

[0051] The scratchpad area and the shared module area are different regions of non-volatile memory. The scratchpad area does not run programs; it is only used for data transfer, such as downloading and storing temporary data. Since the program does not run on the scratchpad area, it will not crash due to changes in the scratchpad data. The shared module area stores shared modules, and the corresponding instances and configuration parameters generated by these shared modules can be used during program execution to achieve a specific function. One scratchpad area can correspond to multiple shared module areas, eliminating the need to reserve a separate scratchpad area for each module, thus enabling scratchpad sharing and conserving non-volatile memory resources. The non-volatile memory can be flash memory.

[0052] Shared modules are stored in the shared module area of ​​non-volatile memory and can be used to generate corresponding data or function instantiations to process corresponding business data and implement corresponding business functions. For example, this could involve instantiating a structure; the structure is data converted from the shared module to volatile memory; this structure can be an Application Binary Interface (ABI), which supports calling structures by memory address but does not support calling structures by name. Unlike Application Programming Interfaces (APIs), which call data by function names and rely on designer-defined interface semantics, often resulting in data being consumed with each call, the ABI, based on memory address calls, directly determines the data in memory through register usage, stack layout, and other ABI rules. Because this method bypasses function interfaces, data can reside in memory without being destroyed during data reading. Therefore, the same structure in the shared module can be called by both the program and the application, allowing non-volatile memory to use fewer addresses to store the structure.

[0053] The program to be updated before flashing is based on a shared module and runs accordingly. The program can be a bootloader or an application. Each shared module can be updated individually to ensure the desired processing results. Each shared module implements a portion of the functions of the program to be flashed.

[0054] In some embodiments, when the bootloader or application runtime conditions are met, a structure for the application binary interface is generated based on the shared module, and the structure is initialized to obtain the target instance. A pre-flash program is then run based on the target instance; the pre-flash program includes the bootloader or the application. Thus, since the application binary interface can bypass the function interface and directly read data from memory, the data can reside in memory without destroying all instances due to data reading. This allows the same structure in the shared module to be called by both the bootloader and the application, enabling the non-volatile memory to use fewer addresses to store the shared module, saving non-volatile memory resources. Furthermore, since the bootloader and application can implement shareable functions based on the same shared module code, only one copy of the source code and configuration is maintained, avoiding defects caused by bootloader and application version drift. Therefore, the shared instance can be reused by the application, saving volatile memory storage resources.

[0055] Step 204: In response to the write command, acquire and store data in the temporary storage area to obtain temporary data; determine the update sharing module and non-update sharing module corresponding to the temporary data, and update the sharing module to be updated based on the temporary data to obtain the updated sharing module.

[0056] A flash command is used to update data in a specific module. It can be used to update shared modules, allowing the bootloader and application program to update data based on the same shared module to perform their respective functions. Optionally, the flash command can be sent from a host computer to the target chip.

[0057] Temporary data is used to update shared modules. This temporary data can be transmitted from a host computer or from other chips to the temporary storage area. It is used to update at least one shared module, thereby updating the shared module to be updated in the non-volatile memory.

[0058] The shared module to be updated is the shared module data that requires data updates. The original data of the shared module to be updated is used to generate the original instance corresponding to the original data to support the operation of the program before the refresh. The target chip determines when the original data is replaced, so that the shared module to be updated containing the original data becomes the updated shared module containing the updated data. The non-updating shared module is the shared module data that does not require data updates. In the absence of a refresh, the non-updating shared module includes all shared modules except the shared module to be updated; the non-updating shared module is used to support the operation of the program before and after the refresh.

[0059] In some embodiments, the update-shared module corresponding to the temporary data is determined based on the module description data contained in the temporary data; non-update-shared modules are determined based on shared modules other than the update-shared module. Thus, the temporary data carries module description data, which can be used to obtain the corresponding update-shared module to implement the corresponding data update process. The module description data can be a unified shared module header data structure, such as an index for verification and error correction, the starting address and address length for determining the range of the shared module, the version of the shared module, and verification data, etc.

[0060] In one embodiment, multiple original instances are obtained by instantiating and assigning values ​​to multiple shared modules; a bootloader before refresh is run based on the original instances; if the update conditions of the bootloader are met, temporary module data is obtained and stored in a temporary storage area; among the multiple shared modules, the updated shared module and the non-updated shared module corresponding to the temporary module data are determined; if the update conditions are met, the shared module to be updated is updated based on the temporary data to obtain the updated shared module.

[0061] Therefore, the data update process of the shared module includes the storage process of temporary data and the data update process of the shared module. Since the temporary data is not directly used to run the program, when the program runs based on the corresponding instance of the updated shared module, the target chip can obtain the corresponding temporary data through the temporary storage area, which will not cause the program to malfunction before the refresh and avoid instruction fetching abnormalities and communication interruptions caused by directly erasing and writing the communication module during operation. After the temporary data is stored in the temporary storage area, the target chip can decide the timing or conditions for updating the data, forming a complete modular software operation and maintenance closed loop.

[0062] Step 206: Based on the shared module to be updated and multiple non-updated shared modules, run the flashed program; the pre-flash program and the post-flash program include at least a portion of the bootloader and / or application programs before and after the update.

[0063] The flashed program runs after the shared module update is complete. It can update its functionality based on the updated shared module, thus updating at least part of the program before and after the update. The same updated shared module and its initialization instances can be used in both the bootloader and the application program.

[0064] In some embodiments, a structure of the application binary interface is generated based on the shared module to be updated and multiple non-updating shared modules, and the structure is initialized to obtain a flashed instance; the target program is run according to the flashed instance; the target program includes a bootloader or an application program.

[0065] In the above program flashing method, a pre-flashing program is generated and run based on multiple shared modules; in response to the flashing command, data is acquired and stored in a temporary storage area to obtain temporary data; the shared modules to be updated and those not to be updated corresponding to the temporary data are determined, and the shared modules to be updated are updated based on the temporary data to obtain the updated shared modules; the post-flashing program is run based on the shared modules to be updated and multiple non-updating shared modules; the pre-flashing program and the post-flashing program include at least part of the bootloader and / or application programs before and after the update. Therefore, both the bootloader and the application programs run based on shared modules, and the update of the shared modules can replace the update of the entire program, significantly shortening the upgrade time and reducing communication overhead; moreover, since the temporary storage area and the shared module area are different areas of non-volatile memory; and the shared module area stores shared modules, which are used to run the pre-flashing program and the post-flashing program, while the temporary storage area does not run programs but is only used for data updates of the shared modules, there will be no program crashes due to changes in the data in the temporary storage area.

[0066] Furthermore, compared to alternating between different versions of the shared module area, it is not necessary to reserve a corresponding temporary storage area for each module, thus enabling the sharing of the temporary storage area, saving storage space of non-volatile memory, and saving storage resources.

[0067] In some embodiments, such as Figure 3 As shown, the pre-flash program is generated and run based on multiple shared modules, including step 302; correspondingly, the post-flash program is run based on the shared module to be updated and multiple non-updating shared modules, including step 304; wherein:

[0068] Step 302: Instantiate and assign values ​​to each shared module according to the address range of multiple shared modules in the non-volatile memory to obtain the original instance of each shared module; run the pre-flash program based on the original instance of each shared module.

[0069] The shared module address range is used to indicate the location of the shared module in the non-volatile memory, so that the corresponding shared module can be extracted into the volatile memory to form the corresponding instance. Since the shared module address ranges are independent of each other, each shared module can be used or updated independently, thereby obtaining the corresponding original instance.

[0070] The original instance is the result of instantiating and assigning values ​​to the various shared modules that have not been updated. Optionally, the original instance can be an independent image that can be downloaded or canceled separately, or it can process corresponding business data to achieve corresponding functions.

[0071] In some embodiments, when updating a shared module based on an Application Programming Interface (API), the address range of the shared module can be determined based on the index of the shared module.

[0072] In other embodiments, when using the application binary interface, the original instance includes an original shared instance, a non-shared first original instance, and a non-shared second original instance. When the bootloader execution conditions are met, shared modules are obtained according to the address range of multiple shared modules in non-volatile memory. A structure of the application binary interface in volatile memory is generated based on the shared modules, and shared and non-shared structures are determined within the structure. The shared structures are instantiated and assigned values ​​to obtain the original shared instance. The non-shared structures are instantiated and assigned values ​​to obtain the non-shared first original instance. When the bootloader execution conditions are met, the pre-flash bootloader is run based on the original shared instance and the non-shared first original instance.

[0073] Specifically, under the condition that the application runs, the non-shared structure is instantiated and assigned values ​​according to the application configuration parameters of the shared module, resulting in a second non-shared original instance. Under the condition that the application runs, the application before flashing is run based on the original shared instance and the second non-shared original instance. Specifically, the bootloader before flashing runs based on the data indicated by the shared pointer and the data indicated by the first non-shared pointer; the application before flashing runs based on the data indicated by the shared pointer and the data indicated by the second non-shared pointer. Thus, by switching pointers between the application and the bootloader, data from different shared modules can be seamlessly integrated or removed, improving the flexibility and maintainability of the software architecture.

[0074] Step 304: Assign values ​​and instantiate the updated shared module according to the address range of the updated shared module to obtain the updated instance; run the flashing program based on the updated instance and the original instances of multiple non-updated shared modules.

[0075] The address range of the updated shared module is the same as that of the shared module to be updated. This is because the updated shared module and the shared module to be updated are different versions of the shared module.

[0076] The updated instance is based on the result of instantiation and assignment of the updated shared module. Optionally, the updated instance can be an independent image, which can be downloaded or canceled separately, or it can process corresponding business data to achieve corresponding functions.

[0077] Since the shared modules to be updated and the non-updated shared modules have different address ranges, the update processes of each shared module do not interfere with each other and can be carried out independently; therefore, the updated instance obtained based on the updated shared module can support the running process of the refreshed program together with the original instance of the non-updated shared module.

[0078] In some embodiments, each shared module is compiled into non-volatile memory along with the bootloader. After compilation, post-processing tools such as HexView can be used to extract the shared modules from the bootloader image into independent files based on their address ranges, forming the shared module address ranges for each independent file of the shared module, facilitating subsequent instantiation and assignment processes. Correspondingly, in response to a flash command, after acquiring data, the newly acquired data is burned to the target chip's starting address offset to the starting address of the temporary storage area, obtaining temporary data; and after extracting the temporary storage area into independent module images, the shared module to be updated can be replaced with the updated shared module according to the shared module address range of the shared module to be updated, thus obtaining the shared module address range of the updated shared module.

[0079] In some embodiments, the updated instance includes an updated shared instance, a non-updated first shared instance, and a non-updated second shared instance; when the bootloader execution conditions are met, shared modules are obtained according to the address range of multiple shared modules in non-volatile memory; a structure of the application binary interface in volatile memory is generated based on the shared modules, and the shared structure and non-shared structure in the structure are determined; the shared structure is instantiated and assigned values ​​to obtain the updated shared instance; the non-shared structure is instantiated and assigned values ​​to obtain the non-updated first shared instance; when the bootloader execution conditions are met, the flashed bootloader is run according to the updated shared instance and the non-updated first shared instance.

[0080] Specifically, under the condition that the application runs, the non-shared structure is instantiated and assigned values ​​according to the application configuration parameters of the shared module, resulting in a non-updated second shared instance. Under the condition that the application runs, the flashed application is run based on the updated shared instance and the non-updated second shared instance. Specifically, the flashed bootloader is run based on the data indicated by the shared pointer and the data indicated by the first non-shared pointer; the flashed application is run based on the data indicated by the shared pointer and the data indicated by the second non-shared pointer. Thus, by switching pointers between the application and the bootloader, data from different shared modules can be seamlessly integrated or removed, improving the flexibility and maintainability of the software architecture.

[0081] In this embodiment, the address ranges of the shared modules in the non-volatile memory are decoupled, allowing each shared module to describe its own location through the shared address range. Therefore, the corresponding shared module can be replaced by temporary data through the shared module address range, realizing the update of a single shared module. This decouples the update logic of the shared modules, supports writing only a single shared module without re-flashing the entire APP, significantly shortens the upgrade time and communication volume, improves the maintainability of the software architecture, and enhances the efficiency of the production line and after-sales service.

[0082] In some embodiments, the shared module includes module body data, the starting address of the shared module, and the address length.

[0083] Based on the address range of multiple shared modules in the non-volatile memory, each shared module is instantiated and assigned a value to obtain the original instance of each shared module. This includes: selecting data of address length according to the starting address of each shared module to obtain the original data of each module body; and instantiating and assigning a value to the original data of each module body to obtain the original instance of each shared module.

[0084] Correspondingly, according to the address range of the updated shared module, the updated shared module is assigned and instantiated to obtain the updated instance, including: selecting data of address length according to the starting address of the updated shared module to obtain the updated shared module; and instantiating and assigning values ​​to the module body data of each module of the updated shared module to obtain the updated instance.

[0085] The module start address is the first address of the shared module's data stored in non-volatile memory. It is used to determine the memory area that needs to provide data, so that the temporary data program in the temporary storage area can be moved to the shared module, instantiated, assigned values, and the call completed. The address length is the amount of data stored by the shared module in non-volatile memory, used to represent the size of the area occupied by the shared module in non-volatile memory.

[0086] The start address and address length of a shared module are module description data for the address range of a shared module, used to standardize the method of determining the address range of a shared module. When using the start address and address length of a shared module, the data in memory is determined directly through binary interface rules such as register usage and stack layout. Because this method can bypass function interfaces, data can reside in memory, allowing the same structure in the shared module to be called by both the bootloader and the application program, thus enabling non-volatile memory to use fewer address storage structures.

[0087] Optionally, the module description data may also include a module identifier and verification data of the shared module, so as to identify the entire shared module by the module identifier, or to analyze whether the temporary data or the shared module is correct by the corresponding verification data.

[0088] Module ontology data is used to implement the functionality contained within a shared module. It can be used to generate pointers, public interfaces, private interfaces, and other functionalities to facilitate the invocation of corresponding functions according to the needs of the bootloader and application. Optionally, pointers are used to select the instance or module configuration parameters required by the bootloader and application; public interfaces are the data read / write interfaces of the shared module, which can be called through pointers; and private interfaces are the interfaces for using functions within the shared module. Corresponding instances can be created through the module ontology data.

[0089] In some embodiments, the starting address of the shared module can be hexadecimal data, such as 0x0806FFFF, and its data length can be 0x10001, which is 65537 bits, used to represent the range of shared module addresses between 0x0806FFFF and 0x0807FFFF.

[0090] In some embodiments, the module ontology data of the original data are instantiated and assigned values ​​to obtain the original instances of each shared module, thereby obtaining the original pointers and original interfaces of each shared module. Correspondingly, according to the starting address of the updated shared module, data of address length is selected to reuse the starting address of the shared module to be updated. After obtaining the updated shared module, the module ontology data of each module of the updated shared module are instantiated and assigned values ​​to obtain the updated pointers and updated interfaces. Optionally, a portion of the data in the shared module to be updated can be updated, or the entire shared module to be updated can be updated.

[0091] In this embodiment, the address range of each shared module is characterized by the starting address and data length of the shared module, so that the granularity of the flushing is set for the specific data length. At this time, data can be updated for the entire shared module or for a part of the shared module, so as to ensure the granularity of the flushing.

[0092] In some embodiments, the program before flashing runs based on the original instance obtained by instantiating and assigning values ​​to the shared module to be updated. Updating the shared module to be updated based on temporary data to obtain the updated shared module includes: determining whether the program before flashing processes business data based on the original instance in the shared module to be updated; if so, continuing to process business data based on the original instance of the shared module to be updated; if not, copying the temporary data to the shared module area corresponding to the shared module to be updated to obtain the updated shared module.

[0093] Business data refers to the data processed by business functions. Since the shared module is used by both the bootloader and the application, this business data and the corresponding business functions are also functions that can be used interchangeably by both the bootloader and the application.

[0094] The shared module implements business functions including, but not limited to, a communication stack, a driver layer, and complex drivers (Cdd). The communication stack includes, but is not limited to: a Diagnostic Communication Manager (Dcm), a PDU Router (PduR), a CAN Transport Protocol (CanTp), a CAN Interface (CanIf), a LIN Transport Protocol (LinTp), and a LIN Interface (LinIf). The driver layer includes, but is not limited to: an Analog-to-Digital Converter (Adc), a Clock Driver (Clock), a Timer Driver (Timer), a Serial Peripheral Interface (Spi), a Controller Area Network (CAN), and a Local Interconnect Network (Lin). Complex drivers (Cdd) include, but are not limited to: an External Watchdog (extWdg) and a System Basis Chip (SBC). These shared modules are not stored separately in the bootloader and applications, but exist independently of the bootloader and applications, and can be called directly through compile-time symbolic links or function addresses.

[0095] In one embodiment, before the target chip or shared module is reset, the corresponding shared module to be updated can be updated to form a complete update of the shared module. When the processor has not run any code corresponding to the shared module to be updated, the entire shared module to be updated can be updated; when the processor has not run the code corresponding to a portion of the shared module to be updated, the code corresponding to the unrunn portion of the shared module to be updated can be updated to form a partial data update within the shared module to be updated.

[0096] In this embodiment, specific business data is processed through the original instance to realize the corresponding business functions. In order to guide the program and application to continue to use the shared module and not to affect the continuous use of the program due to the flashing process, when processing business data based on the original instance in the shared module to be updated, the corresponding shared module is updated in a targeted manner when it is not run, so as to reduce the impact of the flashing process on the business functions.

[0097] In some embodiments, copying temporary data to the shared module area corresponding to the shared module to be updated to obtain the updated shared module includes: determining the program validity flag and the data to be wiped in the shared module to be updated; deleting the data to be wiped while retaining the program validity flag, and copying the temporary data to the shared module area to obtain the updated shared module.

[0098] The program validity flag is used to indicate that the module to be updated is usable, so that the target chip can determine that the function of the shared module is continuously available and can characterize that this function and the corresponding program can run normally. Optionally, the program validity flag can be a global variable inside the shared module, which can be represented by an identifier such as 1 or 0.

[0099] The data to be wiped is the data that needs to be deleted; it can be data used to generate the original instance. The version information of the data to be wiped precedes the version information of the temporary data. The data to be wiped is pending updates, and the temporary data is used to update the data to be wiped.

[0100] In one embodiment, the program validity flag can be an application valid flag, which can be stored in flash memory to identify whether the application is valid. The bootloader can use this program validity flag to determine whether the target chip should jump to the application.

[0101] In one embodiment, the reset of the program validity flag is skipped when the erase address is equal to the shared module temporary storage address, ensuring that the application remains callable during and after the shared module upgrade, thus avoiding rewriting the application.

[0102] In this embodiment, during the data update process, the program's valid flag ensures that the shared module's functionality remains usable before and after the update. Therefore, during the reset process of each shared module's update process, the target chip can determine that the program is running normally.

[0103] In some embodiments, the shared module includes verification data; updating the shared module to be updated based on temporary data to obtain the updated shared module includes: if the temporary data is deemed qualified based on the verification data in the temporary data, copying the temporary data to the shared module area where the shared module to be updated is located to obtain copied data; if the copied data is deemed qualified based on the verification data in the copied data, obtaining the updated shared module based on the qualified copied data.

[0104] Verification data is used to verify data obtained by including verification data; copied data is data that has been stored in the corresponding shared module area, and the data transfer process has been completed. Its usability can be determined as needed. Temporary data and copied data can be verified using the same or different methods. Optionally, the validity of temporary data and copied data can be determined based on Cyclic Redundancy Check (CRC), Longitudinal Redundancy Check (LRC), or other preset verification methods.

[0105] In some embodiments, the original shared module is erased, and then the temporary data is copied to the shared module area where the shared module to be updated is located, to obtain the copied data.

[0106] In some embodiments, a modulo-2 division operation is performed on the temporary data to obtain the remainder of the temporary data after the modulo-2 division. If there is no remainder after the modulo-2 division between the check data in the temporary data and the remainder of the temporary data, then the temporary data is qualified. And / or, a modulo-2 division operation is performed on the copied data to obtain the remainder of the copied data after the modulo-2 division. If there is no remainder after the modulo-2 division between the check data in the copied data and the remainder of the copied data, then the copied data is qualified.

[0107] In some embodiments, qualified copied data can be used as the updated shared module; alternatively, mapping can be performed based on the qualified copied data, and the updated shared module can be obtained according to the mapping result. Optionally, version tracking and CRC integrity verification steps can be performed through a unified module header, with automatic rollback if verification fails, ensuring upgrade security.

[0108] In this embodiment, the corresponding temporary data is first stored in the temporary storage area, and then the shared module is updated based on the temporary data. This process involves at least two rounds of data transfer. Therefore, the temporary data and the copied data are verified separately to ensure the accuracy of the data in the updated shared module. Only when the program is completely error-free can the shared module be updated.

[0109] In some embodiments, acquiring and storing data in a temporary storage area to obtain temporary data includes: acquiring data sent by a host computer, adjusting the address indicated by the acquired data sent by the host computer to the address of the temporary storage area, and obtaining temporary data; wherein the storage space occupied by the temporary storage area is not less than the storage space occupied by the largest shared module.

[0110] The data sent by the host computer is external to the target chip, which can be data sent by the programmer. Since traditional technology directly updates the entire boot program and application program, in order to be compatible with the host computer of traditional technology, the address of the target chip is changed to the address of the temporary storage area to ensure compatibility.

[0111] The address of the temporary storage area is an address in non-volatile memory. It can be the starting address of the temporary storage area to directly store data from the host computer into the temporary storage area; the address of the temporary storage area can also be the address of temporary data that has been copied to the shared module area to avoid excessive usage.

[0112] The temporary storage area occupies a storage space no less than that of the largest shared module. This means that the memory address range occupied by the temporary storage area is greater than or equal to the maximum storage space of each shared module, ensuring that the update process of any shared module can be implemented based on this temporary storage area.

[0113] In some embodiments, the data sent by the host computer includes a bootloader image for updating, and the starting address of the bootloader image is offset to the starting address of the temporary storage area so that the temporary storage area obtains a downloadable independent module image.

[0114] In this embodiment, the address indicated by the data sent by the host computer is adjusted so that the address pointing to the application program is changed to the address pointing to the temporary storage area. This allows multiple shared modules to be updated based on the temporary storage area. Moreover, the storage space occupied by the temporary storage area is greater than the storage space occupied by the largest shared module. Since the temporary storage area does not run directly, it is not necessary to reserve a corresponding temporary storage area for each module, thus realizing the sharing of the temporary storage area and saving storage resources of non-volatile memory.

[0115] In one specific embodiment, traditional techniques cannot update a single shared module individually; the entire application code must be re-flashed, which is time-consuming, involves a large amount of communication, and significantly impacts production line and after-sales upgrade efficiency. Furthermore, traditional flashing resets the APP's validity flag, rendering the ECU unable to run application functions during flashing and after a failure. Risking the entire APP failure for fixing a minor defect in a driver module is too costly. Moreover, communication drivers such as CAN are involved in the flashing process; directly erasing their code in the runtime area will cause instruction fetching anomalies and communication interruptions, leading to the flashing process crashing. Therefore, it is impossible to directly update the module itself during runtime. In addition, there is a lack of module self-description: traditional images do not include module-level metadata (version, address, verification), making it impossible to perform integrity verification and version tracking for individual modules, and hindering modular operation and maintenance.

[0116] Based on this, on the ABI shared module architecture, shared modules (such as CanDrv) are stored separately in a dedicated module Flash area within the bootloader's address space, and a unified module header (including module index, starting address, data length, version, and CRC) is defined for each shared module. During flashing, the module data is first downloaded to an independent temporary storage area via UDS. After verifying its integrity, the bootloader copies the temporary data from the temporary storage area to the module's dedicated area. The entire process does not touch the APP's valid flag, thus achieving independent, atomic, and secure upgrades of shared modules without affecting the normal operation and effectiveness of the application.

[0117] The non-volatile memory layout involves allocating independent regions for shared modules within the bootloader address space and adding temporary storage areas. An example of this layout is shown in Table 1. Table 1 is as follows:

[0118]

[0119] Table 1

[0120] The shared module area is a dedicated Flash address space for each shared module, with a margin reserved upwards based on the current size of the module (e.g., if CanDrv occupies 7.3KB, 8KB is reserved) to facilitate future upgrades. The temporary storage area does not run programs; it is only used for data transfer. To avoid crashes caused by directly erasing or writing modules involved in the flashing process (such as the CAN driver), a temporary storage area with a size no smaller than the largest shared module is reserved. New module data is first downloaded here, and after verification, it is copied to the shared module area by the bootloader.

[0121] Each shared module binary begins with a unified module header data structure, followed by the module body data used to execute the corresponding program functions. The module header data structure is as follows:

[0122] typedef struct {

[0123] uint16_t moduleIndex; / * Module index * /

[0124] uint32_t startAddress; / * Module start address * /

[0125] uint32_t dataLength; / * Module data length * /

[0126] uint8_t version[4]; / * Module version number * /

[0127] uint32_t crc; / * Module CRC checksum * /

[0128] SharedModule_HeaderType;

[0129] The module header enables each module to be self-descriptive, supporting version tracking and integrity verification.

[0130] The unified shared module header data structure (index / address / length / version / CRC) enables module self-description, and the unified module header supports version tracking and CRC integrity verification. If the verification fails, it will automatically roll back to ensure upgrade security.

[0131] In some embodiments, the description focuses on the pre- and post-flashing stages. During this phase, the original shared module is compiled into the target chip along with the bootloader, and the pre-flashing program is run using this. After compilation, it is post-processed using tools such as HexView, and extracted into independent files from the bootloader image according to the module address range. These independent module images facilitate the updating of each shared module. If no flashing program is needed, the corresponding original instance can be obtained based on the original shared module, and the pre-flashing program can be run based on this original instance. However, to adapt to the update process, when the host computer flashes the new module data to the target chip, it offsets the starting address of the flashing process to the starting address of the download buffer. The corresponding code and comments are as follows:

[0132] / / Extract shared modules from BTL image

[0133] HexView.exe / S Btl_Can_FlashDriver.srec / AR:0x1C000,0x1D000 / XS:32:2-o Can_Shared.s19

[0134] / / Offset the starting address to the temporary storage area

[0135] HexView.exe / S / MO:Can_Shared.s19`;0x62000 / XS:32:2 -o Can_Shared.s19

[0136] In some embodiments, taking the complete flashing process of an automotive chip as an example, the Unified Diagnostic Services (UDS) flashing service sequence can be used (the first code is 10 03 Extend Session, the next code is 31 Precondition Check, the next code is 85 Disable DTC, the next code is 28 Disable Communication, the next code is 10 02 Programming Session, the next code is 27 Secure Access, the next code is 2E Fingerprint, the next code is 34 / 36 / 37 Download Flash Driver, the next code is 31 Driver Integrity, the next code is 31 Erase, the next code is 34 / 36 / 37 Download, the next code is 31 Dependency Check, the next code is 11 01 Reset, the next code is 10 03, the next code is 28 Enable Communication, the next code is 85 Enable DTC, the next code is 10 01, the next code is 14 Clear DTC). Among them, 10 03, 31, etc. are the instruction codes of the Unified Diagnostic Services protocol under the automotive diagnostic communication protocol defined by ISO 14229.

[0137] In this embodiment, the following differentiated processing is performed on the shared module during the download process: the target address for downloading the new module data sent by the programmer is a temporary storage area, which is not a module-specific area and does not run programs, thus avoiding crashes caused by directly erasing and writing to a running module; after the download is completed, the data in the temporary storage area is first checked for integrity (such as CRC), and copying is only performed after the check passes; the module's start address and length are read from the module header, and the data is copied from the temporary storage area to the module's dedicated Flash area; after the copy is completed, the module's dedicated area is checked for integrity again; when flashing the shared module, the APP validity flag is not reset, so that when the erase address is equal to the shared module's temporary storage area address, the reset of the APP validity flag is skipped, ensuring that the APP remains valid during and after the shared module upgrade, without needing to re-flash the APP; in addition, if the check fails, the copy is stopped, the original module data is retained, the module maintains the original version of operation, and the upgrade is safely rolled back.

[0138] This embodiment can be applied to any shared module with a binary interface (CAN / LIN / CRC / Flash driver, etc.). Based on module header verification and a pattern of downloading to a temporary storage area first, and then transferring from the temporary storage area to the shared module area, it can be used to support independent flashing of each shared module. Optionally, the copying of the temporary storage area can be evolved into an asynchronous operation. After downloading, a UDS response is returned first, and the copying is performed in the background, with a 0x78 pending response used to keep it alive, shortening the host computer's blocking time. Furthermore, the module header can be extended with a digital signature field, adding authenticity verification in addition to integrity verification to prevent unauthorized modules from being flashed. Additionally, a list of installed shared modules is maintained in the storage area where the Data Identifier (DID) is located, supporting version queries and on-demand rollback to historical module versions. The Data Identifier is used to identify the data items being read or written.

[0139] In this embodiment, the shared module area and the temporary storage area are two independent Flash regions, forming a two-stage flashing layout. Furthermore, a unified shared module header data structure (index / address / length / version / CRC) enables module self-description. During the two-stage flashing, the data is first downloaded to the temporary storage area, then its integrity is verified based on the temporary storage data, then copied to the shared module area, and verified again based on the complex data in the shared module. Additionally, a conditional judgment mechanism that does not reset the APP validity flag is used when flashing the shared module. After compilation, an independent downloadable module image is generated through address range extraction and address offset, facilitating the updating of existing modules with new module data.

[0140] Based on this, this embodiment avoids runtime crashes by using a two-stage writing process involving downloading a temporary storage area and copying, thus avoiding instruction fetching anomalies and communication interruptions caused by directly erasing and writing to the communication module during operation. This embodiment offers refined upgrade granularity, meaning it supports flashing only a single shared module without re-flashing the entire application, significantly reducing upgrade time and communication volume, and improving production line and after-sales efficiency. Furthermore, the application remains valid; flashing the shared module does not reset the application's validity flag, and the ECU application functions are available before and after the upgrade, avoiding business interruptions caused by traditional flashing. Additionally, the module is self-describing and verifiable: the unified module header supports version tracking and CRC integrity verification, automatically rolling back upon verification failure to ensure upgrade security. Therefore, this embodiment can adopt an ABI shared architecture for collaboration, eliminating duplicate module storage and enabling independent updates of shared modules, forming a complete modular software operation and maintenance closed loop.

[0141] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0142] Based on the same inventive concept, this application also provides a program flashing device for implementing the program flashing method described above. The solution provided by this device is similar to the solution described in the above method. Therefore, the specific limitations of one or more program flashing device embodiments provided below can be found in the limitations of the program flashing method above, and will not be repeated here.

[0143] In one embodiment, such as Figure 4 As shown, a program flashing device is provided, applied to a target chip. The non-volatile memory of the target chip includes a temporary storage area and multiple shared module areas for the boot program and application programs. Each of the shared module areas stores a shared module. The device includes:

[0144] Module 402 is used to generate and run the pre-flash program based on multiple shared modules;

[0145] The update module 404 is used to respond to the write command, acquire and store data in the temporary storage area to obtain temporary data; determine the shared module to be updated and the non-updated shared module corresponding to the temporary data, and update the shared module to be updated based on the temporary data to obtain the updated shared module.

[0146] The running module 402 is used to run the flashed program based on the shared module to be updated and multiple non-updated shared modules; the program before flashing and the program after flashing include at least a portion of the bootloader and / or the application program before and after the update.

[0147] In one embodiment, the operation module 402 is configured to:

[0148] According to the address range of multiple shared modules in the non-volatile memory, each shared module is instantiated and assigned a value to obtain the original instance of each shared module; based on the original instance of each shared module, the pre-flash program is run;

[0149] According to the address range of the updated shared module, the updated shared module is assigned and instantiated to obtain an updated instance; based on the updated instance and multiple original instances of non-updated shared modules, the flashing program is run.

[0150] In one embodiment, the shared module includes module body data, the starting address of the shared module, and the address length;

[0151] The operation module 402 is used for:

[0152] Based on the starting address of each shared module, select data of the address length to obtain the original data of each module body data;

[0153] The original data of each module ontology is instantiated and assigned values ​​to obtain the original instances of each shared module;

[0154] The updated shared module is obtained by selecting data of the specified address length according to the starting address of the updated shared module.

[0155] The updated shared module's ontology data is instantiated and assigned values ​​to obtain the updated instance.

[0156] In one embodiment, the pre-flash program runs based on the original instance obtained by instantiating and assigning values ​​to the shared module to be updated;

[0157] The update module 404 is used for:

[0158] Determine whether the program before flashing processes business data based on the original instance in the shared module to be updated;

[0159] If so, continue processing business data based on the original instance of the shared module to be updated;

[0160] If not, the temporary data is copied to the shared module area corresponding to the shared module to be updated, to obtain the updated shared module.

[0161] In one embodiment, the update module 404 is configured to:

[0162] Determine the program validity flag and the data to be wiped in the shared module to be updated;

[0163] While retaining the program's valid flag, the data to be wiped is deleted, and the temporary data is copied to the shared module area to obtain the updated shared module.

[0164] In one embodiment, the sharing module includes verification data; the update module 404 is configured to:

[0165] If the temporary data is deemed qualified based on the verification data in the temporary data, the temporary data is copied to the shared module area where the shared module to be updated is located, and the copied data is obtained.

[0166] If the copied data is deemed qualified based on the verification data in the copied data, an updated sharing module is obtained based on the qualified copied data.

[0167] In one embodiment, the update module 404 is configured to:

[0168] The system acquires data sent by the host computer, adjusts the address indicated by the acquired data sent by the host computer to the address of the temporary storage area, and stores the data sent by the host computer in the temporary storage area to obtain the temporary storage data.

[0169] The storage space occupied by the temporary storage area is not less than the storage space occupied by the largest shared module.

[0170] Each module in the aforementioned program flashing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or they can be stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0171] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 5As shown, the computer device includes a processor, memory, input / output interface, communication interface, display unit, and input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interface. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The input / output interface is used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a program flashing method. The display unit of the computer device is used to form a visually visible image. It can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0172] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0173] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0174] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0175] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0176] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0177] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0178] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0179] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for flashing a program, characterized in that, Applied to a target chip, the non-volatile memory of the target chip includes a temporary storage area and multiple shared module areas for the bootloader and application programs, each of the shared module areas storing a shared module. The method includes: The program is generated and run based on multiple shared modules before flashing. In response to the write command, data is acquired and stored in the temporary storage area to obtain temporary data; the shared module to be updated and the non-updated shared module corresponding to the temporary data are determined, and the shared module to be updated is updated based on the temporary data to obtain the updated shared module; Based on the shared module to be updated and multiple non-updated shared modules, the flashing program is run; the pre-flashing program and the flashing program include at least a portion of the bootloader and / or the application program before and after the update.

2. The method according to claim 1, characterized in that, The pre-flash program, generated and run based on multiple shared modules, includes: According to the address range of multiple shared modules in the non-volatile memory, each shared module is instantiated and assigned a value to obtain the original instance of each shared module; based on the original instance of each shared module, the pre-flash program is run. The process of running the flashed program based on the shared module to be updated and multiple non-updating shared modules includes: According to the address range of the updated shared module, the updated shared module is assigned and instantiated to obtain an updated instance; based on the updated instance and multiple original instances of non-updated shared modules, the flashing program is run.

3. The method according to claim 2, characterized in that, The shared module includes module body data, the starting address of the shared module, and the address length; The step of instantiating and assigning values ​​to each of the shared modules according to the address range of multiple shared modules in the non-volatile memory to obtain the original instances of each shared module includes: Based on the starting address of each shared module, select data of the address length to obtain the original data of each module body data; The original data of each module ontology is instantiated and assigned values ​​to obtain the original instances of each shared module; The step of assigning and instantiating the updated shared module according to the address range of the updated shared module to obtain the updated instance includes: The updated shared module is obtained by selecting data of the specified address length according to the starting address of the updated shared module. The updated shared module's ontology data is instantiated and assigned values ​​to obtain the updated instance.

4. The method according to claim 1, characterized in that, The program before flashing runs based on the original instance obtained by instantiating and assigning values ​​to the shared module to be updated; The step of updating the shared module to be updated based on the temporary data to obtain the updated shared module includes: Determine whether the program before flashing processes business data based on the original instance in the shared module to be updated; If so, continue processing business data based on the original instance of the shared module to be updated; If not, the temporary data is copied to the shared module area corresponding to the shared module to be updated, to obtain the updated shared module.

5. The method according to claim 4, characterized in that, The step of copying the temporary data to the shared module area corresponding to the shared module to be updated, to obtain the updated shared module, includes: Determine the program validity flag and the data to be wiped in the shared module to be updated; While retaining the program's valid flag, the data to be wiped is deleted, and the temporary data is copied to the shared module area to obtain the updated shared module.

6. The method according to claim 1, characterized in that, The shared module includes verification data; updating the shared module to be updated based on the temporary data to obtain the updated shared module includes: If the temporary data is deemed qualified based on the verification data in the temporary data, the temporary data is copied to the shared module area where the shared module to be updated is located, and the copied data is obtained. If the copied data is deemed qualified based on the verification data in the copied data, an updated sharing module is obtained based on the qualified copied data.

7. The method according to claim 1, characterized in that, The process of acquiring and storing data in the temporary storage area to obtain temporary data includes: The system acquires data sent by the host computer, adjusts the address indicated by the acquired data sent by the host computer to the address of the temporary storage area, and stores the data sent by the host computer in the temporary storage area to obtain the temporary storage data. The storage space occupied by the temporary storage area is not less than the storage space occupied by the largest shared module.

8. A program flashing device, characterized in that, Applied to a target chip, the non-volatile memory of the target chip includes a temporary storage area and multiple shared module areas for the bootloader and application programs, each of the shared module areas storing a shared module; the device includes: The runtime module is used to generate and run the pre-flash program based on multiple shared modules; The update module is used to respond to the write command, acquire and store data in the temporary storage area to obtain temporary data; determine the shared module to be updated and the non-updated shared module corresponding to the temporary data, and update the shared module to be updated based on the temporary data to obtain the updated shared module. The running module is used to run the flashed program based on the shared module to be updated and multiple non-updated shared modules; the pre-flash program and the post-flash program include at least a portion of the bootloader and / or the application program before and after the update.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.