Program writing method and device and computer readable storage medium

By flexibly adjusting the writing order of the Bootloader program according to the program type, the problem of high risk of MCU startup failure is solved, and the stability of the system is improved.

CN121541903APending Publication Date: 2026-02-17JIANGSU GUOINNOVATION ENERGY COMMERCIAL VEHICLE INNOVATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511639605.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-10
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

The fixed writing order of the Bootloader program update in the existing technology is not flexible enough, which leads to a high risk of MCU startup failure and poor system stability.

Method used

Based on the type of program to be updated, the writing order of target program information and configuration information is adaptively determined. By using an appropriate writing order, the risk of MCU startup failure is reduced and system stability is improved.

Benefits of technology

By selecting an appropriate writing order, the risk of MCU startup failure during program updates is reduced, thus improving system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121541903A_ABST
    Figure CN121541903A_ABST
Patent Text Reader

Abstract

The invention relates to a program writing method and device and a computer readable storage medium, and relates to the technical field of electronic information. The program writing method comprises the steps that a first program and a second program are determined in starting programs of a chip, the first program is a program to be updated, and the second program is used for updating the first program; according to the type of the first program, the writing sequence of target program information of the first program and target configuration information of the first program is determined, and the target configuration information is used for indicating that the first program meets the running condition; and writing the target program information and the target configuration information into the storage space of the chip by utilizing the second program according to the writing sequence so as to update the first program. According to the technical scheme, the stability of the system can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of electronic information technology, and in particular to a program writing method, a program writing device, a computer-readable storage medium, and a computer program product. Background Technology

[0002] Microcontroller units (MCUs) are widely used in various embedded systems. To facilitate updates to MCU applications, many systems are equipped with a bootloader program to guide the application's execution. As the functionality of embedded devices is upgraded, the bootloader program also needs to be updated. To avoid disassembling and returning the MCU to the factory for bootloader program updates, MCUs typically employ a multi-level boot loading mechanism, allowing updates to the bootloader program used to guide the application's execution to be performed by other bootloader programs.

[0003] In related technologies, during the Bootloader program update process, the new version of the Bootloader program is written in the order of first writing the reset configuration half-word of the Bootloader program, and then writing the complete program information. Summary of the Invention

[0004] The inventors of this disclosure have discovered the following problems in the above-mentioned related technologies: the fixed writing order is not flexible enough, which makes the risk of MCU startup failure high and results in poor system stability.

[0005] In view of this, this disclosure proposes a program writing technology solution that can adaptively determine the writing order of the information of the program to be updated according to the type of the program to be updated, reduce the risk of MCU startup failure, and thus improve the stability of the system.

[0006] According to some embodiments of this disclosure, a program writing method is provided, comprising: determining a first program and a second program in a chip's boot program, wherein the first program is a program to be updated and the second program is used to update the first program; determining the writing order of target program information and target configuration information of the first program according to the type of the first program, wherein the target configuration information is used to indicate that the first program meets the operating conditions; and using the second program, writing the target program information and target configuration information into the chip's storage space according to the writing order to update the first program.

[0007] In some embodiments, the boot program includes a first boot program, which is used to boot the application program of the chip to run. In response to the first program being the first boot program, the target program information is determined to be written before the target configuration information is written.

[0008] In some embodiments, a first program is determined based on the current configuration information of the first startup program, the current configuration information being used to indicate whether the startup program meets the running conditions; and a second program corresponding to the first program is determined based on the type of the first program.

[0009] In some embodiments, in response to the current configuration information of the first startup program indicating that the first startup program does not meet the running conditions, the first startup program is determined as the first program; in response to the current configuration information of the first startup program indicating that the first startup program meets the running conditions, the first program is determined in the startup program based on whether there is an update request for the startup program.

[0010] In some embodiments, among the startup programs targeted by the update request, a first program is determined according to the update priority, wherein the update priority of the first startup program is higher than the update priority of the second startup program, and the second startup program is another startup program besides the first startup program.

[0011] In some embodiments, in response to the first program being a startup program other than the first startup program, the first startup program is determined to be the second program; in response to the first program being the first startup program, it is determined whether the second startup program is determined to be the second program based on whether the second startup program meets the update execution conditions.

[0012] In some embodiments, in response to the second startup program meeting the update execution conditions, the second startup program is determined as the second program; in response to the second startup program not meeting the update execution conditions, the second startup program is updated using the first startup program; and the updated second startup program is determined as the second program.

[0013] In some embodiments, it is determined whether the first startup program meets the update execution conditions; in response to the first startup program meeting the update execution conditions, the second startup program is updated using the first startup program.

[0014] In some embodiments, updating execution conditions includes informing the launcher that the launcher meets the running conditions based on its current configuration information.

[0015] In some embodiments, in response to the first program completing an update, it is determined whether there is an update request for the application on the chip; in response to the existence of an update request for the application on the chip, the application is updated using the first launcher.

[0016] According to some other embodiments of this disclosure, a program writing apparatus is provided, comprising: a first determining unit, configured to determine a first program and a second program in a chip's boot program, wherein the first program is a program to be updated and the second program is used to update the first program; a second determining unit, configured to determine the writing order of target program information and target configuration information of the first program according to the type of the first program, wherein the target configuration information is used to indicate that the first program meets operating conditions; and an updating unit, configured to use the second program to write the target program information and target configuration information into the chip's storage space according to the writing order, so as to update the first program.

[0017] In some embodiments, the startup program includes a first startup program for bootstrapping the chip's application program. The second determining unit determines the target program information earlier than the target configuration information in response to the first program being the first startup program.

[0018] In some embodiments, the first determining unit determines a first program based on the current configuration information of the first startup program, wherein the current configuration information is used to indicate whether the startup program meets the running conditions; and determines a second program corresponding to the first program based on the type of the first program.

[0019] In some embodiments, the first determining unit determines the first startup program as the first program in response to the current configuration information of the first startup program indicating that the first startup program does not meet the running conditions; in response to the current configuration information of the first startup program indicating that the first startup program meets the running conditions, the first program is determined in the startup program based on whether there is an update request for the startup program.

[0020] In some embodiments, the first determining unit determines a first program in the startup program targeted by the update request according to the update priority, wherein the update priority of the first startup program is higher than the update priority of the second startup program, and the second startup program is another startup program besides the first startup program.

[0021] In some embodiments, the first determining unit determines the first startup program as the second program in response to the first program being a startup program other than the first startup program; and in response to the first program being the first startup program, determines whether to determine the second startup program as the second program based on whether the second startup program meets the update execution conditions.

[0022] In some embodiments, the first determining unit determines the second startup program as the second program in response to the second startup program meeting the update execution conditions; in response to the second startup program not meeting the update execution conditions, it updates the second startup program using the first startup program; and the updated second startup program is determined as the second program.

[0023] In some embodiments, the first determining unit determines whether the first startup program meets the update execution conditions; in response to the first startup program meeting the update execution conditions, the second startup program is updated using the first startup program.

[0024] In some embodiments, updating execution conditions includes informing the launcher that the launcher meets the running conditions based on its current configuration information.

[0025] In some embodiments, in response to the completion of the first program update, the update unit determines whether there is an update request for the application on the chip; in response to the existence of an update request for the application on the chip, it updates the application using the first startup program.

[0026] According to further embodiments of the present disclosure, a program writing apparatus is provided, comprising: a memory; and a processor coupled to the memory, the processor being configured to execute the program writing method of any of the above embodiments based on instructions stored in the memory apparatus.

[0027] According to further embodiments of the present disclosure, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the program writing method of any of the above embodiments.

[0028] According to further embodiments of this disclosure, a computer program product is also provided, including instructions that, when executed by a processor, cause the processor to perform the program writing method according to any of the foregoing embodiments.

[0029] In the above embodiments, the writing order of target program information and target configuration information is adaptively determined according to the type of program to be updated, enabling the system to select a more suitable update method for different types of startup programs. In this way, by selecting an appropriate writing order, the risk of MCU startup failure during program updates can be reduced, thereby improving system stability. Attached Figure Description

[0030] The accompanying drawings, which form part of this specification, illustrate embodiments of this disclosure and, together with the specification, serve to explain the principles of this disclosure.

[0031] This disclosure will become clearer with reference to the accompanying drawings and the following detailed description, wherein:

[0032] Figure 1 Flowcharts illustrating some embodiments of the program writing method of this disclosure;

[0033] Figure 2 Schematic diagrams illustrating some embodiments of the chips disclosed herein;

[0034] Figure 3Flowcharts illustrating other embodiments of the program writing method of this disclosure;

[0035] Figure 4 Block diagrams illustrating some embodiments of the program writing apparatus of this disclosure;

[0036] Figure 5 Block diagrams illustrating other embodiments of the program writing apparatus of this disclosure;

[0037] Figure 6 Block diagrams illustrating further embodiments of the program writing apparatus of this disclosure are shown. Detailed Implementation

[0038] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values ​​of the components and steps set forth in these embodiments do not limit the scope of the present disclosure.

[0039] At the same time, it should be understood that, for ease of description, the dimensions of the various parts shown in the accompanying drawings are not drawn according to actual scale.

[0040] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit this disclosure or its application or use.

[0041] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.

[0042] In all examples shown and discussed herein, any specific values ​​should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values.

[0043] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.

[0044] For example, the technical solution of this disclosure can be implemented through the following embodiments.

[0045] Figure 1 Flowcharts illustrating some embodiments of the program writing method of this disclosure are shown.

[0046] like Figure 1 As shown, in step 110, a first program and a second program are determined in the chip's startup program. The first program is the program to be updated, and the second program is used to update the first program. For example, the chip includes an MCU (such as an MPC5744 chip).

[0047] For example, the bootloader includes a first bootloader, which is used to bootstrap the chip's application program. The bootloader includes a bootloader program, and the first bootloader can be a first bootloader program that boots the application.

[0048] In step 120, the writing order of the target program information and the target configuration information of the first program is determined according to the type of the first program. The target configuration information is used to indicate that the first program meets the running conditions. For example, the target configuration information includes a reset configuration half-word for a new version of the program to be updated. If the reset configuration half-word is valid, it can indicate that the Bootloader program is fully functional.

[0049] For example, the condition for a reset configuration half-word to be valid can be that the first byte of the reset configuration half-word is hexadecimal 01h and the second byte is hexadecimal 5Ah.

[0050] In step 130, the second program, following the writing order, writes the target program information and target configuration information into the chip's storage space to update the first program. For example, the chip's storage space includes Flash memory sectors.

[0051] In the above embodiments, the writing order of target program information and target configuration information is adaptively determined according to the type of program to be updated, enabling the system to select a more suitable update method for different types of startup programs. In this way, by selecting an appropriate writing order, the risk of MCU startup failure during program updates can be reduced, thereby improving system stability.

[0052] The determination process of the first procedure and the second procedure in step 110 above is illustrated below through some embodiments.

[0053] In some embodiments, a first program is determined based on the current configuration information of the first startup program, the current configuration information being used to indicate whether the startup program meets the running conditions; and a second program corresponding to the first program is determined based on the type of the first program.

[0054] For example, the current configuration information includes the reset configuration half-word of the first bootloader program. After the MCU is powered on or reset, it searches for a valid reset configuration half-word in multiple Flash memory sectors from low to high addresses.

[0055] In some embodiments, in response to the current configuration information of the first startup program indicating that the first startup program does not meet the running conditions, the first startup program is determined as the first program; in response to the current configuration information of the first startup program indicating that the first startup program meets the running conditions, the first program is determined in the startup program based on whether there is an update request for the startup program.

[0056] For example, if the reset configuration half-word of the first bootloader program is found, it is determined whether the reset configuration half-word of the first bootloader program is valid. If the reset configuration half-word of the first bootloader program is invalid, it can be determined that the first bootloader program is not fully functional, and the first bootloader program is identified as the first program.

[0057] For example, a power outage during MCU update of the bootloader program may invalidate the reset configuration half-word of the first bootloader program.

[0058] In this way, even if a power outage occurs during the update process of the first bootloader program, causing its reset configuration half-word to fail, the second bootloader program, which meets the operating conditions, can be enabled to update the first bootloader program, thereby enhancing the fault tolerance of the boot process and improving the overall reliability of the system.

[0059] The following examples illustrate, by way of example, a method for determining the program to be updated when the first startup program meets the running conditions.

[0060] In some embodiments, among the startup programs targeted by the update request, a first program is determined according to the update priority, wherein the update priority of the first startup program is higher than the update priority of the second startup program, and the second startup program is another startup program besides the first startup program.

[0061] For example, if the reset configuration half-word of the first bootloader program is valid, it can be determined that the first bootloader program is fully functional and runs. First, it can be determined whether the first bootloader program needs to be updated. If the first bootloader program needs to be updated, it is designated as the first program. If the first bootloader program does not need to be updated, but the second bootloader program (e.g., the second bootloader program) needs to be updated, the second bootloader program is designated as the first program.

[0062] In this way, by setting a higher update priority for the first bootloader program, the update needs of the more important first bootloader program are met first, provided that the system functions normally, thus ensuring the reliability of system startup.

[0063] The following examples illustrate how to determine a second program that updates the first program.

[0064] In some embodiments, in response to the first program being a startup program other than the first startup program, the first startup program is determined to be the second program; in response to the first program being the first startup program, it is determined whether the second startup program is determined to be the second program based on whether the second startup program meets the update execution conditions. For example, the update execution conditions include the current configuration information of the startup program indicating that the startup program meets the running conditions.

[0065] For example, as mentioned earlier, the determination of whether the second bootloader program is the first program is only made if the first bootloader program meets the running conditions. Therefore, in response to the first program being the second bootloader program, the first bootloader program is identified as the second program, and the second bootloader program is updated using the first bootloader program. However, in response to the first program being the first bootloader program, it is necessary to first determine whether the second bootloader program meets the running conditions before deciding whether to use the second bootloader program to update the first bootloader program.

[0066] In some embodiments, in response to the second startup program meeting the update execution conditions, the second startup program is determined as the second program; in response to the second startup program not meeting the update execution conditions, the second startup program is updated using the first startup program; and the updated second startup program is determined as the second program.

[0067] For example, if the reset configuration half-word of the second bootloader program is invalid, the second bootloader program can be updated first using the first bootloader program. Then, the updated second bootloader program can be used for further updates.

[0068] For example, determine whether the first startup program meets the update execution conditions; in response to the first startup program meeting the update execution conditions, use the first startup program to update the second startup program.

[0069] For example, the first bootloader program might need to be updated because its reset configuration half-word is invalid, or it might need to be updated because there is an update request for the first bootloader program. In other words, if the first bootloader program needs to be updated, it cannot be determined whether the first bootloader program meets the update execution conditions. Therefore, it is possible to determine whether the first bootloader program's reset configuration half-word is valid in order to ascertain whether the first bootloader program meets the update execution conditions.

[0070] In this way, by updating each other between the first and second bootloader programs, it is ensured that there is always a usable bootloader program in the system to perform updates, thereby guaranteeing the reliability of program update capabilities and improving system stability under the multi-level boot loading mechanism.

[0071] The following examples illustrate the process of determining the writing order in step 120 above.

[0072] In some embodiments, in response to the first program being the first bootloader, it is determined that the target program information was written before the target configuration information. For example, if the reset configuration half-word of the second bootloader program is valid, the first bootloader program is updated using the second bootloader program.

[0073] For example, during the update process of the first bootloader, the current version of the first bootloader program can be erased from the storage space, that is, the current program information and current configuration information of the first bootloader program can be erased. Then, during the writing of the new version of the first bootloader program, the target program information of the first bootloader program can be written first, and the target configuration information of the first bootloader program, that is, the reset configuration half-word of the new version program, can be written last.

[0074] In this way, when updating the bootloader program used to boot the application (e.g., the first bootloader program), by writing the target configuration information later than the target program information, the MCU is prevented from being guided to incomplete program information by valid target configuration information. This reduces the risk of MCU startup failure due to interruption of the bootloader program update process, thereby improving system stability.

[0075] In some embodiments, in response to the first program completing an update, it is determined whether there is an update request for the application on the chip; in response to the existence of an update request for the application on the chip, the application is updated using the first launcher.

[0076] For example, if the reset configuration half-word of the first bootloader program is valid, and neither the first nor the second bootloader program needs to be updated, then it is determined whether the application needs to be updated. If the application needs to be updated, it is updated; otherwise, the application runs normally.

[0077] In the above embodiments, the writing order of target program information and target configuration information is adaptively determined according to the type of program to be updated, enabling the system to select a more suitable update method for different types of bootloader programs. Furthermore, when updating the first bootloader program used to guide the application's execution, by writing the target configuration information later than the target program information, the MCU is prevented from being guided to incomplete program information by valid target configuration information. This reduces the risk of MCU boot failure due to interruption of the bootloader update process, thereby improving system stability.

[0078] The following is through Figure 2 The embodiments described above exemplify a chip system that performs the above-described program writing method.

[0079] Figure 2 Schematic diagrams illustrating some embodiments of the chips disclosed herein.

[0080] like Figure 2 As shown, chip 2 includes a first bootloader program 21, a second bootloader program 22, and an application program 23. The first bootloader program 21 is used to boot the application program and can communicate with the second bootloader program 22, allowing the second bootloader program 22 to be updated using the first bootloader program 21. The second bootloader program 22 is a different bootloader program than the first bootloader program 21 and only communicates with the first bootloader program 21. The application program 23 communicates with the first bootloader program 21 and can also be updated using the first bootloader program 21.

[0081] During the update process of the first bootloader program 21, the original version of the first bootloader program 21 is first erased from the storage space, then the complete target program information of the new version of the first bootloader program 21 is written, and finally the target configuration information of the new version of the first bootloader program 21 is written. For the update of the second bootloader program, the order in which the target configuration information and the target program information are written is not restricted.

[0082] By selecting the writing order as described above, the system can adaptively choose the most suitable update method for different types of bootloaders. For the first bootloader program that guides the application to run, the above writing order can prevent the MCU from being guided by valid target configuration information to incomplete program information, reducing the risk of MCU boot failure caused by interruption of the bootloader update process, thereby improving system stability.

[0083] The following is through Figure 3 The embodiments in the example are based on Figure 2 The chip structure in the example illustrates the technical solution for executing the above-described program.

[0084] Figure 3 Flowcharts illustrating some other embodiments of the program writing method of this disclosure are shown.

[0085] In some embodiments, the MPC5744 chip can be used. In step 310, the MCU is controlled to reset or power on. Then, step 315 is executed, starting from the boot address offset 00h, querying from the low address to the high address to see if there is a reset configuration half-word that meets the valid conditions. The valid conditions can be: the first byte of the reset configuration half-word is hexadecimal 01h, and the second byte is hexadecimal 5Ah.

[0086] For example, the reset configuration half-word of the first bootloader program at the low address is first retrieved. The reset configuration half-word of the first bootloader program is hexadecimal 015Ah. The validity of this reset configuration half-word indicates that the first bootloader program is fully functional, so step 320 is executed to run the first bootloader program. Then step 325 is executed to determine whether the first bootloader program needs to be updated.

[0087] In response to the need to update the first bootloader program, step 330 is executed to check if the second bootloader reset configuration half-word is hexadecimal 015Ah (i.e., to determine if the second bootloader program's reset configuration half-word is valid). If the second bootloader program's reset configuration half-word is valid, indicating that the second bootloader program is functionally complete, step 335 is executed. If the second bootloader program's reset configuration half-word is invalid, step 340 is executed.

[0088] In step 335, the second bootloader program is run, and the first bootloader program is updated using the second bootloader program. First, the original version of the first bootloader program is erased in the storage space, then the complete target program information of the new version of the first bootloader program is written, and finally the reset configuration half-word (i.e., target configuration information) of the new version of the first bootloader program is written.

[0089] If the first bootloader program does not need to be updated, proceed to step 345 to determine if the second bootloader program needs to be updated. If the reset configuration half-word of the second bootloader program is not hexadecimal 015Ah (i.e., the reset configuration half-word of the second bootloader program is invalid) or there is an update request for the second bootloader program, proceed to the aforementioned step 340.

[0090] In step 340, the second bootloader program is updated. During the update process, the current program information and current configuration information of the second bootloader program are first erased, and then the reset configuration half-word and new version program information of the second bootloader program are written. The order in which the target configuration information and target program information are written is not restricted for updating the second bootloader program.

[0091] During the Bootloader program update process in steps 335 and 340, step 350 can also be executed to determine whether the MCU experienced a power outage during the flashing of the new version program. If the MCU did not experience a power outage, proceed to step 355, and the program update is successful. If the MCU experienced a power outage, return to step 310 to reset the MCU and re-execute the above steps.

[0092] In the event of a power failure in the MCU, the reset configuration half-word of the first bootloader program may not be hexadecimal 015Ah, meaning the reset configuration half-word of the first bootloader program is invalid. Therefore, step 360 is executed.

[0093] In step 360, it is determined whether the reset configuration half-word of the second bootloader program is hexadecimal 015Ah (i.e., whether the reset configuration half-word of the second bootloader program is valid). If the reset configuration half-word of the second bootloader program is also invalid, proceed to step 365, and the MCU startup fails. If the reset configuration half-word of the second bootloader program is valid, proceed to step 370.

[0094] In step 370, the second bootloader program is run, and then step 335 as described above is executed to update the first bootloader program using the second bootloader program.

[0095] If neither the first bootloader program nor the second bootloader program needs to be updated or both have been updated, proceed to step 375.

[0096] In step 375, it is determined whether the application needs to be updated. If the application does not need to be updated, step 380 is executed to run the application. If the application needs to be updated, step 385 is executed.

[0097] In step 385, the application is updated. First, the current version of the application's program information is erased, and then the new version of the application is written. During the application update process, step 350 mentioned above can be executed to determine whether the MCU experiences a power outage during the flashing of the new version of the program. If the MCU does not experience a power outage, proceed to step 355, and the program update is successful. If the MCU experiences a power outage, return to step 310 to reset the MCU and re-update the application using the first Bootloader program.

[0098] In the above embodiments, when updating the first bootloader program, the target configuration information is written later than the target program information, thus preventing the MCU from being effectively reset to the configuration half-word and booting into incomplete program information. During the entire update process, a power outage occurring only during a short period (e.g., 10 milliseconds) when the reset configuration half-word of the first bootloader program is written could prevent the MCU from starting normally. This reduces the risk of MCU startup failure due to a power outage during the program update process, thereby improving the reliability of the program update and the stability of the system.

[0099] Figure 4 Block diagrams illustrating some embodiments of the program writing apparatus of this disclosure are shown.

[0100] According to some other embodiments of this disclosure, a program writing device 4 is provided, comprising: a first determining unit 41, configured to determine a first program and a second program in the chip's boot program, wherein the first program is a program to be updated and the second program is used to update the first program; a second determining unit 42, configured to determine the writing order of target program information and target configuration information of the first program according to the type of the first program, wherein the target configuration information is used to indicate that the first program meets the operating conditions; and an updating unit 43, configured to use the second program to write the target program information and target configuration information into the chip's storage space according to the writing order, so as to update the first program.

[0101] In some embodiments, the startup program includes a first startup program, which is used to guide the application program of the chip to run. In response to the first program being the first startup program, the second determining unit 42 determines that the target program information is written earlier than the target configuration information.

[0102] In some embodiments, the first determining unit 41 determines a first program based on the current configuration information of the first startup program, wherein the current configuration information is used to indicate whether the startup program meets the running conditions; and determines a second program corresponding to the first program based on the type of the first program.

[0103] In some embodiments, the first determining unit 41 determines the first startup program as the first program in response to the current configuration information of the first startup program indicating that the first startup program does not meet the running conditions; in response to the current configuration information of the first startup program indicating that the first startup program meets the running conditions, the first program is determined in the startup program based on whether there is an update request for the startup program.

[0104] In some embodiments, the first determining unit 41 determines a first program in the startup program targeted by the update request according to the update priority. The update priority of the first startup program is higher than the update priority of the second startup program. The second startup program is a startup program other than the first startup program.

[0105] In some embodiments, the first determining unit 41 determines the first startup program as the second program in response to the first program being a startup program other than the first startup program; and in response to the first program being the first startup program, determines whether to determine the second startup program as the second program based on whether the second startup program meets the update execution conditions.

[0106] In some embodiments, the first determining unit 41 determines the second startup program as the second program in response to the second startup program meeting the update execution conditions; in response to the second startup program not meeting the update execution conditions, it updates the second startup program using the first startup program; and determines the updated second startup program as the second program.

[0107] In some embodiments, the first determining unit 41 determines whether the first startup program meets the update execution conditions; in response to the first startup program meeting the update execution conditions, the second startup program is updated using the first startup program.

[0108] In some embodiments, updating execution conditions includes informing the launcher that the launcher meets the running conditions based on its current configuration information.

[0109] In some embodiments, in response to the completion of the first program update, the update unit 43 determines whether there is an update request for the application on the chip; in response to the existence of an update request for the application on the chip, it updates the application using the first startup program.

[0110] In the above embodiments, the writing order of target program information and target configuration information is adaptively determined according to the type of program to be updated, enabling the system to select a more suitable update method for different types of bootloader programs. Furthermore, when updating the first bootloader program used to guide the application's execution, by writing the target configuration information later than the target program information, the MCU is prevented from being guided to incomplete program information by valid target configuration information. This reduces the risk of MCU boot failure due to interruption of the bootloader update process, thereby improving system stability.

[0111] Figure 5 Block diagrams illustrating other embodiments of the program writing apparatus of this disclosure are shown.

[0112] like Figure 5 As shown, the program writing device 4 of this embodiment includes a memory 51 and a processor 52 coupled to the memory 51. The processor 52 is configured to execute the program writing method in any embodiment of this disclosure based on instructions stored in the memory 51.

[0113] The memory 51 may include, for example, system memory, fixed non-volatile storage media, etc. The system memory stores, for example, the operating system, application programs, boot loader, database, and other programs.

[0114] Figure 6 Block diagrams illustrating further embodiments of the program writing apparatus of this disclosure are shown.

[0115] like Figure 6 As shown, the program writing device 4 of this embodiment includes a memory 51 and a processor 52 coupled to the memory 51. The processor 52 is configured to execute the program writing method of any of the foregoing embodiments based on instructions stored in the memory 51.

[0116] The memory 51 may include, for example, system memory, fixed non-volatile storage media, etc. The system memory stores, for example, the operating system, application programs, boot loader, and other programs.

[0117] The program writing device 4 may also include an input / output interface 630, a network interface 640, and a storage interface 650. These interfaces 630, 640, and 650, as well as the memory 51 and processor 52, can be connected via, for example, a bus 660. The input / output interface 630 provides a connection interface for input / output devices such as a monitor, mouse, keyboard, touchscreen, microphone, and speakers. The network interface 640 provides a connection interface for various networked devices. The storage interface 650 provides a connection interface for external storage devices such as SD cards and USB flash drives.

[0118] Those skilled in the art will understand that embodiments of this disclosure can be provided as methods, systems, or computer program products. Therefore, this disclosure can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this disclosure can take the form of a computer program product embodied on one or more computer-usable non-transitory storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0119] The program writing method, program writing apparatus, and computer-readable storage medium according to this disclosure have been described in detail. To avoid obscuring the concept of this disclosure, some details known in the art have not been described. Those skilled in the art will fully understand how to implement the technical solutions disclosed herein based on the above description.

[0120] The methods and systems of this disclosure may be implemented in many ways. For example, they may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order of steps for the methods is for illustrative purposes only, and the steps of the methods of this disclosure are not limited to the specific order described above unless otherwise specifically stated. Furthermore, in some embodiments, this disclosure may also be implemented as a program recorded on a recording medium, the program including machine-readable instructions for implementing the methods according to this disclosure. Thus, this disclosure also covers recording media storing programs for performing the methods according to this disclosure.

[0121] While specific embodiments of this disclosure have been described in detail by way of examples, those skilled in the art should understand that the examples are for illustrative purposes only and are not intended to limit the scope of this disclosure. Those skilled in the art should understand that modifications can be made to the above embodiments without departing from the scope and spirit of this disclosure.

Claims

1. A method for writing a program, comprising: In the chip's startup program, a first program and a second program are determined. The first program is the program to be updated, and the second program is used to update the first program. Based on the type of the first program, the writing order of the target program information and the target configuration information of the first program is determined, wherein the target configuration information is used to indicate that the first program meets the running conditions; Using the second program, the target program information and the target configuration information are written into the chip's storage space according to the writing order to update the first program.

2. The program writing method according to claim 1, wherein, The startup program includes a first startup program, which is used to guide the application program of the chip to run. The step of determining the writing order of the target program information and the target configuration information of the first program according to the type of the first program includes: In response to the first program being the first startup program, it is determined that the target program information was written earlier than the target configuration information.

3. The program writing method according to claim 2, wherein, Determining the first program and the second program in the chip's startup program includes: The first program is determined based on its current configuration information, wherein the current configuration information is used to indicate whether the program meets the running conditions. Based on the type of the first program, determine the second program corresponding to the first program.

4. The program writing method according to claim 3, wherein, The step of determining the first program based on the current configuration information of the first startup program includes: In response to the current configuration information of the first startup program indicating that the first startup program does not meet the running conditions, the first startup program is identified as the first program; In response to the current configuration information of the first launcher indicating that the first launcher meets the operating conditions, the first launcher is determined in the launcher based on whether there is an update request for the launcher.

5. The program writing method according to claim 4, wherein, The current configuration information of the first startup program indicates that the first startup program meets the operating conditions, and the first program is determined to include, based on whether there is an update request for the startup program, the following: Among the startup programs targeted by the update request, the first program is determined according to the update priority, and the update priority of the first startup program is higher than that of the second startup program. The second startup program is another startup program besides the first startup program.

6. The program writing method according to claim 3, wherein, The step of determining the second program corresponding to the first program based on the type of the first program includes: In response to the first program being a startup program other than the first startup program, the first startup program is determined to be the second program; In response to the first program being the first startup program, the system determines whether to identify the second startup program as the second program based on whether the second startup program meets the update execution conditions.

7. The program writing method according to claim 6, wherein, The step of determining whether to identify the second startup program as the second program in response to the first program being the first startup program includes: In response to the second startup program satisfying the update execution conditions, the second startup program is determined to be the second program; In response to the second startup program not meeting the update execution conditions, the second startup program is updated using the first startup program; The updated second startup program is selected as the second program.

8. The program writing method according to claim 7, wherein, The step of updating the second startup program using the first startup program in response to the second startup program not meeting the update execution conditions includes: Determine whether the first startup program meets the update execution conditions; In response to the first startup program meeting the update execution conditions, the second startup program is updated using the first startup program.

9. The program writing method according to claim 6, wherein, The update execution conditions include the current configuration information of the startup program indicating that the startup program meets the running conditions.

10. The program writing method according to any one of claims 2-9, further comprising: In response to the first program completing the update, determine whether there is an update request for the application of the chip; In response to an application update request for the chip, the application is updated using the first launcher.

11. A program writing device, comprising: The first determining unit is used to determine a first program and a second program in the chip's startup program, wherein the first program is a program to be updated, and the second program is used to update the first program; The second determining unit is used to determine the writing order of the target program information and the target configuration information of the first program according to the type of the first program, wherein the target configuration information is used to indicate that the first program meets the running conditions. An update unit is used to use the second program to write the target program information and the target configuration information into the chip's storage space according to the writing order, so as to update the first program.

12. A program writing device, comprising: Memory; and A processor coupled to the memory, the processor being configured to execute the program writing method of any one of claims 1-10 based on instructions stored in the memory.

13. A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the program writing method according to any one of claims 1-10.

14. A computer program product comprising instructions that, when executed by a processor, cause the processor to perform the program writing method according to any one of claims 1-10.