MCU application program online upgrading and starting method based on UWB wireless communication

The online upgrade method of MCU application programs through UWB wireless communication and partitioned storage areas solves the problem of limited online upgrade of electronic equipment, realizes efficient and stable remote upgrade and program redundant backup, and improves upgrade efficiency and reliability.

CN120631394APending Publication Date: 2025-09-12SOUTHWEST PETROLEUM UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510692937.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-27
Publication Date
2025-09-12

Smart Images

  • Figure CN120631394A_ABST
    Figure CN120631394A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of data management, and provides an MCU application program online upgrading and starting method based on UWB wireless communication, and the method comprises the following steps: (1) resetting a processor and initializing configuration; (2) countdown is started, if no instruction is received in the countdown, program starting operation is executed, if the instruction is received in the countdown, instruction operation is executed, and when the instruction type is an upgrading instruction, data of the program to be upgraded are downloaded, and upgrading is completed. After the processor is electrified and reset, countdown is set, and whether to upgrade or start a program is determined according to a data receiving state in the countdown, so that the upgrade operation can be executed and completed in a programmed manner only by uniformly setting the mother end and establishing communication connection between the mother end and the son end; and the problem of low-efficiency operation of realizing upgrading operation through active control of the upper computer is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of data management technology, and in particular relates to an online upgrade and startup method for an MCU application based on UWB wireless communication. Background Art

[0002] With the continuous development and advancement of technology, the systems in many electronic devices need to support automatic online upgrades. Currently, most upgrade methods use debug interfaces to update programs. In practice, engineers cannot reach the designated location to connect, and disassembling and installing many high-value devices is too expensive. Alternatively, applications can be updated via wired interfaces within the processor's application program. However, this is also limited by the application scenario and can easily lead to upgrade failures at long distances, causing the program to freeze at a certain point and requiring a restart.

[0003] Program upgrades and updates through wireless communication can overcome the problem of using interface scenarios, but basically require active control of the host computer to implement the upgrade operation, which will undoubtedly increase the difficulty of operation and reduce the upgrade efficiency.

[0004] Application Contents

[0005] In order to solve the above technical problems, a method for online upgrading and starting an MCU application based on UWB wireless communication is proposed, which is described in detail as follows.

[0006] A method for online upgrading and starting an MCU application based on UWB wireless communication, the method comprising the following steps:

[0007] (1) The processor resets and initializes the configuration;

[0008] (2) Enable countdown. If no instruction is received within the countdown, the startup program operation is executed. If an instruction is received within the countdown, the instruction operation is executed.

[0009] The execution instruction operation includes downloading data of the program to be upgraded to complete the upgrade when the instruction type is an upgrade instruction.

[0010] Furthermore, in step (2), if no instruction is received within the countdown, the following steps are executed:

[0011] (2-1) Read the startup number;

[0012] (2-2) Perform CRC check of the startup number and the program. If the check passes, the program is started. If the check fails, the countdown is reset.

[0013] Furthermore, at least two programs are set up. In step (2-2), a CRC check of the corresponding program is performed according to the read startup number. If the check passes, the corresponding program is started. If the check fails, a CRC check of other programs is performed. If the check passes, the corresponding program is started. If all checks fail, the countdown is returned to reset.

[0014] In addition, when the corresponding program cannot be started according to the read startup number and the CRC check of other programs is completed, the startup number is rewritten corresponding to the program that passed the CRC check.

[0015] Furthermore, when the program is started, the startup number and program version number are returned, and when the countdown is reset, an error message is returned.

[0016] Furthermore, in step (2), when an instruction is received within the countdown, the following is executed:

[0017] (2-3) Determine the instruction type and perform startup and upgrade operations according to the instruction type;

[0018] (2-4) If it is a start command, the CRC check of the start number and the program is performed. If the check passes, the program is started. Otherwise, the countdown is returned and the countdown is reset after receiving the command or the countdown ends.

[0019] (2-5) If it is an upgrade command, the download timer is started and the data of the program to be upgraded is received. After the program is received, a CRC check is performed. If the check passes, the upgrade is completed. If the check fails, the countdown is reset.

[0020] Furthermore, in step (2-5), after the download timing is started, it is determined whether new data is received within the download timing period. If so, the process returns to execute the download and judgment, and if not, the download and judgment are terminated.

[0021] Furthermore, a pre-startup program area, a program area, a startup flag area, a temporary storage area, and a receiving data area are set, wherein at least two program areas are set, and each partition performs erase, read, and write operations independently;

[0022] The pre-boot program area is used to store the pre-boot program execution code, communication interaction method and UWB wireless initialization method;

[0023] The program area is used to store the executable code of the program, which is guided and run by the pre-start program area;

[0024] The startup flag area is used to store the startup number and program version number of the program at startup;

[0025] The temporary storage area is used to store data of programs to be upgraded that have not been verified;

[0026] The receiving data area is used to receive sub-package data of the program to be upgraded.

[0027] Furthermore, in step (2-5), the data of the program to be upgraded that has passed the verification is transferred from the temporary storage area to one of the program areas with the lowest version number, and a new startup number and program version number are returned.

[0028] The beneficial effects of this application are:

[0029] (1) After the processor is powered on and reset, a countdown is set. According to the data reception status within the countdown, it is decided whether to upgrade or start the program. In this way, only the mother end needs to be uniformly set up, and after the mother end and the child end are connected, the upgrade operation can be completed by program execution, thereby avoiding the inefficient operation problem of implementing the upgrade operation through the active control of the host computer;

[0030] (2) It is divided into multiple storage areas, and the programs and data in each area have their own functions. After the online upgrade process is abnormally interrupted, it can be restarted to upgrade again or another version of the application can be started to run. At the same time, another program can be started to run during normal operation. The information in the startup flag area can be used to know the current running program APP version and startup number. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 Shown is a flow chart of a method for online program upgrade and startup;

[0032] Figure 2 The figure shows a schematic diagram of Flash partition. DETAILED DESCRIPTION

[0033] In the following description, certain specific details are set forth in order to provide a thorough understanding of the various embodiments. However, it will be understood by those skilled in the art that the present application can be practiced without these details. In other cases, well-known structures are not shown or described in detail to avoid unnecessarily obscuring the description of the embodiments. Unless the context requires otherwise, throughout the specification and the appended claims, the word "comprising" should be interpreted in an open, inclusive sense, that is, as in "including but not limited to."

[0034] Figure 1 The following is an online upgrade and startup method of MCU application based on UWB wireless communication. Figure 1 As shown, the method includes the following steps:

[0035] (1) The processor resets and initializes the configuration;

[0036] (2) Enable countdown. If no instruction is received within the countdown, the startup program operation is executed. If an instruction is received within the countdown, the instruction operation is executed.

[0037] The processor can have built-in or external software functions of the ultra-wideband (UWB) communication protocol, and communicate with external control terminal devices through the UWB communication protocol. UWB technology based on the UWB communication protocol is a wireless carrier communication technology; the UWB communication protocol has the advantages of fast transmission speed and strong anti-interference ability, providing a stable speed of more than 6.81Mbps within a range of 10 meters, and can transmit data within seconds.

[0038] The MCU (processor) connects to the UWB chip via the SPI interface. The UWB chip uses the IEEE 802.15.4z-2020 protocol. A UWB frame consists of a write command, a control command, the mother-end frame number, the destination address, the source address, the slave-end frame number, a valid data area, and a checksum (automatically generated by the UWB chip). The destination address, source address, and frame number are pre-written, and the data to be updated is placed in the valid data area. After the host sends the updated data to the slave, the slave replies with a frame of data consisting of the response of the previous frame and the data that the slave needs to send to the mother (such as countdown information).

[0039] The device to which the processor belongs is the slave end, and it needs to receive instructions from the master end to complete the upgrade. Accordingly, the master end is also equipped with the software function of the ultra-wideband (UWB) communication protocol to communicate with the slave end through the UWB communication protocol.

[0040] In step (2), if no instruction is received within the countdown, the execution of the startup program operation is essentially the execution of the preset program, which includes the following steps:

[0041] (2-1) Read the startup number;

[0042] (2-2) Perform CRC check of the startup number and the program. If the check passes, the program is started. If the check fails, the countdown is reset.

[0043] In step (2-1), the startup number is information stored in a specific area (startup flag area). The startup number is generally unchanged in the startup flag area. The startup number has a corresponding program, and the startup number represents the program that is started by default each time.

[0044] In step (2), at least two versions of the program to be started are specifically set. Different programs to be started have different startup numbers. Therefore, after reading the startup number, startup operations of different programs will be executed according to different startup numbers.

[0045] For example, taking two versions of programs to be started as an example, namely program 1 and program 2, the process of step (2) is as follows:

[0046] (2-1) Read the startup number (for example, 1, which is the startup number of program 1);

[0047] (2-2) Execute the CRC check of the program (program one) corresponding to the startup number. If the check passes, the corresponding program (program one) is started. If the check fails, execute the CRC check of another program (program two). If the check passes, the other program (program two) is started. If the check fails, return to reset the countdown.

[0048] In addition, when the corresponding program (program 1) cannot be started according to the read startup number (for example, 1) and the CRC check of other programs (program 2) is completed, the startup number of the program that passes the CRC check is rewritten (for example, 2).

[0049] The verification order of program 1 and program 2 in step (2-2) can be reversed.

[0050] In addition, in step (2-2), the startup number and program version number are returned when the program is started, and the error prompt information is returned when the countdown is reset.

[0051] In step (2), if an instruction is received within the countdown, the essence of executing the instruction operation is to execute a temporary control program, including a targeted startup program or upgrade program, and the steps include:

[0052] (2-3) Determine the instruction type and perform startup and upgrade operations according to the instruction type;

[0053] (2-4) If it is a start command, the CRC check of the start number and the program is performed. If the check passes, the program is started. Otherwise, the countdown is returned and the countdown is reset after receiving the command or the countdown ends.

[0054] (2-5) If it is an upgrade command, the download timer is started and the data of the program to be upgraded is received. After the program is received, a CRC check is performed. If the check passes, the upgrade is completed. If the check fails, the countdown is reset.

[0055] Generally speaking, the above steps (2-4) and (2-5) are steps to be selectively executed, and different steps are executed respectively according to the judgment type of the instruction.

[0056] Secondly, in step (2-4), if the verification fails, the countdown is returned and the countdown should also be reset.

[0057] In step (2-5), a judgment operation is also set after starting the download timing to improve the efficiency of program execution. Specifically, it is determined whether new data is received within the download timing period. If so, it indicates that the data of the program to be upgraded has not been received. If not, it indicates that the data of the program to be upgraded has been received. This can avoid the problem of wasting time caused by unnecessary download waiting and the problem of upgrade interruption or failure caused by download disconnection.

[0058] In addition, in order to improve the stability and reliability of program upgrades, a temporary storage area and a program area are set up accordingly. The temporary storage area is used to store data of the program to be upgraded that has not been verified. When the data of the program to be upgraded passes the verification, it is transferred to the program area for startup.

[0059] On the other hand, in combination with the above-mentioned records of this application, when executing the startup program operation, at least two programs will be set for startup. Accordingly, each program needs to set a corresponding program area. Therefore, when setting program one and program two for startup, program area one will also be set accordingly to store the execution code of program one, and program area two will be set to store the execution code of program two.

[0060] Therefore, in step (2-5), after the data of the program to be upgraded passes verification, the data of the program to be upgraded will be transferred to the program area with a smaller version number and replace the execution code stored in the original program area. In this way, by setting up multiple program areas (generally two program areas are sufficient) to store two programs with different version numbers respectively, redundant backup is achieved, which can avoid the problem of being unable to start the program execution operation normally when a problem occurs in the program area itself.

[0061] Similarly, when the data of the program to be upgraded is transferred to the program area, the startup number and program version number will also be returned.

[0062] See also Figure 2 As a system that executes the above-mentioned upgrade method, it is necessary to configure Flash and RAM areas for storing executable codes. Taking the pre-setting of two programs as an example, in this application, the Flash is divided into a pre-startup program area, program area one, program area two and a startup flag area, and the RAM area is divided into a temporary storage area and a receiving data area. Each partition performs erase, read and write operations independently without affecting each other.

[0063] Among them, program area 1 is used for executable code of program 1, and the application pre-start program area guides the operation.

[0064] Program area 2 is used for the executable code of program 2, and the application pre-start program area guides the operation.

[0065] The startup flag area is used to store the startup number of program 1 or program 2 started after online upgrade, the CRC check of program 1 and program 2, and the program version number of program 1 and program 2.

[0066] The temporary storage area is used to temporarily store the application's executable code during online upgrades. During online upgrades, the application's executable code is first stored in the temporary storage area and then subjected to a CRC check. If the check is successful, the executable code is then stored in the designated program area 1 or program area 2.

[0067] The receiving data area is used to receive the sub-package data of the program to be upgraded and then copy it to the temporary storage area.

[0068] The pre-startup program area is used to store the execution code of the pre-startup program, and also includes the communication interaction method and the UWB wireless initialization method. The pre-startup program area needs to start the corresponding program according to the startup number in the startup flag area.

[0069] The communication interaction method in the pre-startup program area is as follows:

[0070] The control end that sends the upgrade command or data periodically initiates a heartbeat packet to detect whether the receiving end is online, and each heartbeat packet contains data length information, data frame number, data type and data CRC check. The receiving end is always in the receiving state and periodically resets the transceiver to avoid device abnormalities. The control end initiates and the receiving end replies each time to avoid simultaneous concurrency on both sides. Each frame of the control end and the receiving end is accompanied by an ACK for the receipt of the previous frame of data. If the sent data is not received, the previous frame of data is resent.

[0071] The data received by the receiving data area is a two-dimensional data, each group of which is 128 bytes long. Each group of data received by the receiving data area also needs to be CRC checked.

[0072] During operation, the pre-startup program area, program area one, and program area two all have the same initialization configuration for the UWB radio. They are also on the same frequency band and have the same communication settings and configuration as the control end that sends upgrade instructions or data, with the addresses set as master and slave. At the same time, the control end can manually start program one or program two via communication, and the startup number and program version number in the startup flag area can be changed to change the program that will be started first next time.

[0073] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them.

Claims

1. A method for online upgrading and starting an MCU application based on UWB wireless communication, characterized in that: The method comprises the following steps: (1) The processor resets and initializes the configuration; (2) Enable countdown. If no instruction is received within the countdown, the startup program operation is executed. If an instruction is received within the countdown, the instruction operation is executed. The execution instruction operation includes downloading data of the program to be upgraded to complete the upgrade when the instruction type is an upgrade instruction.

2. The method for online upgrading and starting an MCU application based on UWB wireless communication according to claim 1, characterized in that: In step (2), if no instruction is received within the countdown, execute: (2-1) Read the startup number; (2-2) Perform CRC check of the startup number and the program. If the check passes, the program is started. If the check fails, the countdown is reset.

3. The method for online upgrading and starting an MCU application based on UWB wireless communication according to claim 2, characterized in that: Set up at least two programs. In step (2-2), perform CRC check of the corresponding program according to the read startup number. If the check passes, start the corresponding program. If the check fails, perform CRC check of other programs. If the check passes, start the corresponding program. If all checks fail, return to reset countdown.

4. The method for online upgrading and starting an MCU application based on UWB wireless communication according to claim 2, characterized in that: When starting the program, the startup code and program version number are also returned. When resetting the countdown, error information is also returned.

5. The method for online upgrading and starting an MCU application based on UWB wireless communication according to claim 1, characterized in that: In step (2), when the command is received within the countdown, the following is executed: (2-3) Determine the instruction type and perform startup and upgrade operations according to the instruction type; (2-4) If it is a start command, the CRC check of the start number and the program is performed. If the check passes, the program is started. Otherwise, the countdown is returned and the countdown is reset after receiving the command or the countdown ends. (2-5) If it is an upgrade command, the download timer is started and the data of the program to be upgraded is received. After the program is received, a CRC check is performed. If the check passes, the upgrade is completed. If the check fails, the countdown is reset.

6. The method for online upgrading and starting an MCU application based on UWB wireless communication according to claim 5, characterized in that: In step (2-5), after the download timing is started, it is determined whether new data is received within the download timing period. If so, the process returns to execute the download and judgment. If not, the download and judgment are terminated.

7. The method for online upgrading and starting an MCU application based on UWB wireless communication according to claim 5, characterized in that: Set up a pre-startup program area, a program area, a startup flag area, a temporary storage area and a receiving data area, wherein at least two program areas are set up, and each partition is independently erased, read and written; The pre-boot program area is used to store the pre-boot program execution code, communication interaction method and UWB wireless initialization method; The program area is used to store the executable code of the program, which is guided and run by the pre-start program area; The startup flag area is used to store the startup number and program version number of the program at startup; The temporary storage area is used to store data of programs to be upgraded that have not been verified; The receiving data area is used to receive sub-package data of the program to be upgraded.

8. The method for online upgrading and starting an MCU application based on UWB wireless communication according to claim 7, characterized in that: In step (2-5), the data of the program to be upgraded that has passed the verification is transferred from the temporary storage area to one of the program areas with the lowest version number, and a new startup number and program version number are returned.