Application program upgrading method, device and system, computer equipment and medium
By simplifying the method of recording variables and determining breakpoint positions, the problem of cumbersome determination of breakpoint positions during remote upgrade of MCU system applications in the prior art is solved, which improves the upgrade efficiency and data recovery transmission speed.
Patent Information
- Application Number
- CN202510088124.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-20
- Publication Date
- 2025-05-16
AI Technical Summary
The remote upgrade data acquisition and update of existing applications depends on the file system and is not suitable for MCU systems. The process of determining breakpoint locations is cumbersome and the data recovery and transmission speed is slow.
By obtaining the application upgrade information, using simple variable recording and determining breakpoint positions, the data breakpoint continuous transmission operation is simplified, and only a fixed breakpoint position needs to be tracked, reducing the complexity of breakpoint search.
Improves the efficiency of application upgrades, simplifies the upgrade process of MCU system, and reduces the time for data recovery and transmission.
Smart Images

Figure CN120010893A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to an application program upgrade method, device, system, computer equipment, and readable storage medium. Background Art
[0002] Nowadays, remote upgrades of applications usually use embedded Linux systems to obtain and update programs. During the remote upgrade process, breakpoint resuming is supported, and the breakpoint position is determined by calculating and comparing the checksum of the sub-packets.
[0003] However, the acquisition and update of remote upgrade data of existing applications rely on the file system, which is not suitable for MCU (Microcontroller Unit) systems, and the process of determining the breakpoint location is cumbersome, and the speed of data recovery transmission is slow. Summary of the invention
[0004] The present application provides an application upgrade method, apparatus, system, computer equipment and readable storage medium, which can improve the upgrade efficiency of the application.
[0005] In a first aspect, the present application provides a method for upgrading an application program, the method comprising:
[0006] Obtaining application upgrade information; the upgrade information includes remote upgrade information and local upgrade information;
[0007] According to the upgrade information of the application, a remote upgrade flag is read from a first global variable used to store the remote upgrade information;
[0008] If the value of the remote upgrade flag is set to a first value, a remote upgrade storage processing flow is executed on the application; if the remote upgrade flag is set to a second value, a local upgrade flag is read from a second global variable used to store the local upgrade information;
[0009] If the value of the local upgrade flag is set to the first value, a local upgrade storage processing flow is executed on the application; if the value of the local upgrade flag is set to the second value, the application is started.
[0010] Optionally, after the remote upgrade storage processing flow of performing remote upgrade on the application, the process further includes:
[0011] Obtaining an upgrade result of the application;
[0012] If the upgrade result is that the application is successfully upgraded, resetting the value of the remote upgrade flag or the value of the local upgrade flag;
[0013] If the upgrade result is that the application upgrade fails, the upgrade process of the application is re-executed.
[0014] Optionally, the remote upgrade storage processing flow for the application includes:
[0015] Reading the remote upgrade program of the application and the upgrade program package of the remote upgrade program;
[0016] Calculate a first checksum according to the size of the upgrade program package;
[0017] Compare the first checksum with the preset checksum, and when the first checksum is equal to the preset checksum, execute the writing process of the remote upgrade program; when the first checksum is not equal to the preset checksum, jump to the check exception handling process;
[0018] Calculate and obtain a second checksum according to the written upgrade program package;
[0019] The second checksum is compared with the preset checksum. If the second checksum is equal to the preset checksum, a remote upgrade success flag is set; if the second checksum is not equal to the preset checksum, a remote upgrade failure flag is set.
[0020] Optionally, the writing process of the remote upgrade program includes:
[0021] Writing the remote upgrade program into a preset storage area of the memory in sequence according to the preset sub-package size to obtain a plurality of program sub-packages;
[0022] A data consistency check is performed on each of the program subpackages. If the check passes, the program subpackage is written into the memory. If the check fails, the process jumps to the check exception handling process.
[0023] Optionally, the method further includes:
[0024] Obtaining a loop variable i at the index position of the program subpackage being processed, and initializing the loop variable i to 0;
[0025] Writing the (i+1)th program subpackage into the preset storage area, and performing a consistency check on the program subpackage;
[0026] When the program subpackage verification passes, the value of the loop variable i is increased by one unit; when the program subpackage verification fails, the process jumps to the verification exception handling process;
[0027] It is determined whether the loop variable i is equal to the total number of program sub-packages. If not, the writing process of the next program sub-package is continued. If equal, the writing process of all program sub-packages is terminated.
[0028] Optionally, before obtaining the upgrade information of the application, the method further includes: obtaining an upgrade frame carrying a data packet for remotely upgrading the application, and parsing the upgrade frame to obtain the upgrade information and upgrade flag of the application;
[0029] The upgrade frame includes a registration frame, an upgrade program start frame, an upgrade program data frame and an upgrade program end frame, wherein:
[0030] The registration frame includes a registration request frame and a registration reply frame, and the registration reply frame is used to carry program version information of the application and device type information of the device;
[0031] The upgrade program start frame includes an upgrade program start request frame and an upgrade program start reply frame, wherein the upgrade program start request frame is used to carry firmware version information, the total number of program packages, program checksum, and a forced update flag; the upgrade program start reply frame is used to carry a result field, the total number of program packages, and a frame sequence number expected to be transmitted;
[0032] The upgrade program data frame includes an upgrade program data request frame and an upgrade program data reply frame, wherein the upgrade program data request frame is used to carry the firmware version information, the total number of program packages, the current transmission package sequence number, and the program data packet, and the upgrade program data reply frame is used to carry the result field, the total number of program packages, and the frame sequence number of the expected transmission;
[0033] The upgrade program end frame includes an upgrade program end request frame and an upgrade program end reply frame. The upgrade program end request frame is used to carry the firmware version information, the program checksum, and the upgrade timestamp. The upgrade program end request frame is used to carry the result field, the firmware version information, and the program checksum.
[0034] Optionally, before obtaining the application upgrade information, the following is also included:
[0035] Verifying the upgrade conditions of the application;
[0036] If the upgrade condition verification of the application fails, then exit the upgrade preparation process of the application; if the upgrade condition verification of the application passes, then determine the upgrade time of the application according to the upgrade information;
[0037] If the format of the upgrade time is wrong, the upgrade preparation process is exited; if the upgrade time has been reached and the format of the upgrade time is correct, the remote upgrade flag is stored in the memory.
[0038] In a second aspect, the present application further provides an application program upgrade device, comprising:
[0039] A data acquisition module, used to acquire application upgrade information; the upgrade information includes remote upgrade information and local upgrade information;
[0040] A flag identification module, used for reading a remote upgrade flag from a first global variable used for storing the remote upgrade information according to the upgrade information of the application program;
[0041] A remote upgrade module, configured to execute a remote upgrade storage processing flow for the application program if the value of the remote upgrade flag is set to a first value; and to read a local upgrade flag from a second global variable for storing the local upgrade information if the remote upgrade flag is set to a second value;
[0042] A local upgrade module is used to execute a local upgrade storage processing flow for the application if the value of the local upgrade flag is set to the first value; and to start the application if the value of the local upgrade flag is set to the second value.
[0043] In a third aspect, the present application also provides an application upgrade system, comprising:
[0044] A microcontroller unit, used to execute the above-mentioned application program upgrade method, wherein the microcontroller unit is divided into a boot program area and an application program area, wherein the boot program area is used to update the upgrade information of the application program to the application program area and execute the jump operation of the application program, and the application program area is used to run the application program and the upgrade program of the application program;
[0045] A flash memory, used for storing temporary remote upgrade information during the process of running the remote upgrade program in the application program area;
[0046] A ferroelectric memory, comprising a remote upgrade information storage area and a local upgrade information storage area, wherein the remote upgrade information storage area is used to store the remote upgrade information, and the local upgrade information storage area is used to store the local upgrade information;
[0047] A remote communication interface, used for transmitting the remote upgrade information;
[0048] The local serial port is used to transmit the local upgrade information.
[0049] In a fourth aspect, the present application also provides a computer device, comprising a processor and a memory; the memory is used to store a computer program; the processor is used to execute the computer program stored in the memory to implement the steps of the application upgrade method as described above.
[0050] In a fifth aspect, the present application also provides a computer-readable storage medium storing a computer program, wherein the computer program is loaded by a processor to perform the steps of the application upgrade method as described above.
[0051] The embodiment of the present application supports the MCU system and uses simple variables to record and determine the breakpoint position, which greatly simplifies the operation of resuming data during the application upgrade process. During the entire upgrade process, only a fixed breakpoint position needs to be tracked, reducing the complexity of breakpoint search, thereby improving the efficiency of application upgrades. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0053] Figure 1 It is a flowchart of the application program upgrade method provided in the embodiment of the present application;
[0054] Figure 2 It is a power curve diagram of a photovoltaic power station in a power-cutting state provided in an embodiment of the present application;
[0055] Figure 3 It is a power curve diagram of a photovoltaic power station in a peak-shaving and power-limiting state provided in an embodiment of the present application;
[0056] Figure 4 It is a power curve diagram of a photovoltaic power station in a current regulation and power limiting state provided in an embodiment of the present application;
[0057] Figure 5 It is a functional module diagram of the application program upgrade device provided in the embodiment of the present application;
[0058] Figure 6 It is a schematic diagram of the structure of the computer device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0059] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0060] In the description of the present application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the feature. In the description of the present application, "plurality" means two or more, unless otherwise clearly and specifically defined.
[0061] In this application, the word "exemplary" is used to mean "used as an example, illustration or description". Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. At the same time, it is to be understood that in the specific implementation of this application, when user information, user data and other related data are involved, when the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data shall comply with relevant laws, regulations and standards of relevant countries and regions.
[0062] In order to enable any person skilled in the art to implement and use the present application, the following description is provided. In the following description, details are listed for the purpose of explanation. It should be understood that those of ordinary skill in the art will recognize that the present application can be implemented without using these specific details. In other examples, known structures and processes will not be elaborated in detail to avoid unnecessary details that make the description of the present application obscure. Therefore, the present application is not intended to be limited to the embodiments shown, but is consistent with the widest range of principles and features disclosed in the present application.
[0063] In the prior art, the identification of power-limited status of photovoltaic power stations usually adopts the following two methods: one is to establish a mapping model through meteorological data or model inverter data, calculate the theoretical power generation of the power station, and compare it with the actual power generation, and determine the power-limited status by setting a deviation threshold. This method relies on external meteorological information and model inverter data to ensure the accuracy of the theoretical power generation. The second is to determine whether there is a power-limited status by calculating the correlation between the actual power curve of the power station and the typical power-limited power curve. This method only needs to use the power data of the power station, avoiding dependence on meteorological data and inverter model data.
[0064] However, the existing practices have obvious shortcomings. On the one hand, the theoretical power calculation method based on meteorological data or sample machine data is applicable to power stations with complete data, but it is difficult to implement in the absence of meteorological data or sample machine inverter data, which limits the scope of application of this method; on the other hand, the method of identifying the power-limiting state by correlation with the typical power-limiting power curve is only applicable to a certain type of power-limiting curve, and it is difficult to cover various types of power-limiting such as power-limiting, peak-shaving and current-regulating power-limiting, resulting in low accuracy and universality of the identification results.
[0065] Therefore, the power limit identification method of the present application can accurately identify different types of power limit states of a photovoltaic power station without relying on meteorological data.
[0066] The present application provides an application upgrade method, apparatus, system, computer device, and readable storage medium, which are described in detail below.
[0067] Figure 1 This is a flow chart of an application upgrade method in one embodiment of the present application. Figure 2 As shown, the application program upgrade method may include the following steps 101-102.
[0068] Step 101: Obtain application upgrade information.
[0069] Among them, the application program, namely APP (APPlication), refers to the program running when the device is working normally, which usually includes the main functions and logical processing of the device, such as data acquisition, control, communication, etc. Among them, the upgrade information is used for the application to record and manage the upgrade status, progress and control data during the remote upgrade process. For example, the upgrade information may include data and information such as the program package required for the upgrade, the upgrade flag, and the timestamp.
[0070] In some embodiments, the upgrade information can be read from a related memory or a storage area of the memory storing the upgrade information. The upgrade information may include remote upgrade information for remotely upgrading the application and local upgrade information for locally upgrading the application. In a specific application, for example, the remote upgrade information may be saved to a remote information storage area of the memory, and the local upgrade information may be saved to a local information storage area of the memory.
[0071] In some embodiments, in the scenario of the present application, the upgrade process of the application can be divided into three stages: the first stage is the upgrade frame parsing, the second stage is the preparation for upgrade after the upgrade data packet is successfully received, and the third stage is in the boot program area, updating the upgrade program to the application area of the device and jumping to the application.
[0072] Therefore, before step 101, an upgrade frame carrying a data packet for remotely upgrading the application program may be acquired, and the upgrade frame may be parsed to obtain upgrade information and an upgrade flag of the application program.
[0073] In some embodiments, during the parsing of the upgrade frame, the data exchange between the application and the system adopts a specific frame format. The beginning of each data frame is marked by a start character (68H), and the end is marked by an end character (16H). The data frame includes a control field and a frame checksum, wherein the checksum is encoded using CRC16, with the high byte first and the low byte last. The system and the device check each data frame. If the checksum does not match, the data frame is discarded and no longer processed to ensure the accuracy of the data.
[0074] In some embodiments, the control field of the upgrade frame may include four types of frames: registration frame, upgrade program start frame, upgrade program data frame, and upgrade program end frame. All data frames are actively initiated by the platform as request frames, and the device interacts with the platform through reply frames.
[0075] As an example only, the format of the upgrade frame may be represented as:
[0076] The start character (68H) marks the beginning of a data frame, and the end character (16H) marks the end of a data frame, as follows:
[0077] Start character (68H) Length L(L1L0) Start character (68H) Sender Link address field (A) Control domain (C) Sequence Payload Frame Checksum (CS) End character (16H)
[0078] The length L has two bytes, which refers to the length of the payload.
[0079] Source Sender ID: The initiator of the frame.
[0080] 0XAA identifies Master: system side;
[0081] 0XB2 identifies Terminal: device side;
[0082] Link address field: 8-byte code, each device has a unique code;
[0083] Control field: 4 bytes encoding the control field of each instruction is different.
[0084] Sequence number: 4-byte code, a unique code for each frame, generated by the host and copied by the slave when replying to the frame;
[0085] The frame checksum is CRC16 coded, with the high byte in front and the low byte in the back. The system and the device check the data frames for interaction. If the checksum is wrong, no processing is performed and the packet data is directly discarded to ensure data accuracy.
[0086]
[0087]
[0088] In some embodiments, the registration frame may include a registration request frame and a registration reply frame, and the registration reply frame is used to carry the program version information of the application and the device type information of the device. Specifically. After the device is connected to the device management platform, the platform can first send a device registration request frame. After the device receives the request frame, it replies with a device registration reply frame. The reply frame contains relevant information about the device, such as: the way the device connects to the platform (such as Ethernet, 4G, Wi-Fi, Bluetooth, etc.), CCID number, MAC address, signal quality, the program version and device type currently running on the APP, etc. Among this information, the program version and device type currently running on the APP are key parameters that the system needs to obtain during the remote upgrade process.
[0089] In some embodiments, the upgrade program start frame may include an upgrade program start request frame and an upgrade program start reply frame. The upgrade program start request frame is used to carry firmware version information, the total number of program packages, the program checksum, and a forced update flag; the upgrade program start reply frame is used to carry the result field, the total number of program packages, and the frame sequence number expected to be transmitted.
[0090] The upgrade program start request frame sent by the system and the upgrade program start reply frame sent by the device can be used to start the remote upgrade process. The system's upgrade program start request frame contains information such as the firmware version, the total number of program packages, the program number (32-bit integer), and the forced update flag. After receiving the request frame, the device returns an upgrade program start reply frame, which contains information such as the result field, the total number of packages, and the frame sequence number that it hopes to receive.
[0091] As an example only, the format of the upgrade procedure start request frame may be represented as:
[0092]
[0093] When the forced update is 1, the device no longer determines the firmware version, and the frame number expected to be transmitted is 1. When the forced update is 0, the device determines the firmware version. If the versions are inconsistent, the device obtains the expected transmission frame based on the stored remote upgrade information.
[0094] In the specific implementation, the parsing process of the upgrade program starting the request frame is as follows:
[0095] First, the device may extract relevant information from the received upgrade start request frame, where the relevant information may include the total number of upgrade program packets, a checksum, a forced upgrade mode flag, and a version number of the upgrade program.
[0096] Next, you can check whether the upgrade program version number extracted in the request frame is consistent with the program version number currently running on the device. If they are consistent, it means that the device is running the latest version, and a "Program version consistent" error reply frame is generated and sent to the platform, and the process ends. If they are inconsistent, proceed to the next step.
[0097] Next, the forced upgrade mode can be detected, and the forced upgrade mode flag can be checked to be set to 1. If the forced upgrade flag is 1, the total number of upgrade program packages and checksum in the remote upgrade information global structure are updated to the total number of packages and checksum in the request frame; the current number of packages to be upgraded is initialized to 1, and the program checksum written in the Flash is set to 0; the remote upgrade information global structure is saved to the remote information storage area of the external ferroelectric memory; a reply frame (including the version of the program to be upgraded, the total number of packages and the current number of packages to be upgraded) is generated and sent to the system, and the process ends. Correspondingly, if the forced upgrade flag is 0, proceed to the next step.
[0098] Next, you can check whether the following contents in the global structure of the upgrade information match the corresponding contents in the request frame, whether the software version is consistent with the version number in the request frame, whether the remote program checksum and the checksum written in the Flash are consistent with the checksum in the request frame, and whether the total number of frames and the current number of frames to be transmitted match those in the request frame (the total number of frames + 1 must be equal to the current number of frames). If all of the above information matches: generate an "upgrade completed" error reply frame and send it to the system, and end the process; if it does not match: proceed to the next step.
[0099] Next, a breakpoint resume check can be performed. If the software version in the global structure of the upgrade information is consistent with the version number in the request frame, and the checksum matches, and the number of frames currently required to be transmitted is less than the total number of packets in the request frame, it indicates that the previous upgrade is not completed, and the breakpoint resume can be continued. The corresponding upgrade program start reply frame (for example, it can include the version of the program to be upgraded, the total number of packets, and the current number of packets to be upgraded) is generated and sent to the system, and the process ends. If the above conditions are not met, proceed to the next step.
[0100] Finally, a new upgrade can be initialized. If the request frame contains a brand new upgrade program, the software version, total number of upgrade program packages and checksum in the request frame are assigned to the global structure of the upgrade information, the current number of packages to be upgraded is initialized to 1, and the program checksum written in the Flash is set to 0; the global structure of the remote upgrade information is saved to the remote information storage area of the external ferroelectric memory; a reply frame is generated (for example, including the version of the program to be upgraded, the total number of packages and the current number of packages to be upgraded) and sent to the system, and the process ends.
[0101] As an example only, the format of the upgrade procedure start reply frame may be represented as:
[0102]
[0103] In some embodiments, the upgrade program data frame may include an upgrade program data request frame and an upgrade program data reply frame. The upgrade program data request frame is used to carry firmware version information, the total number of program packages, the current transmission package sequence number, and the program data packet. The upgrade program data reply frame is used to carry the result field, the total number of program packages, and the frame sequence number expected to be transmitted.
[0104] As an example only, the format of the upgrade program data request frame may be represented as:
[0105]
[0106] In some embodiments, the parsing process of the upgrade program data request frame is as follows:
[0107] First, the upgrade information can be extracted. The device can extract the following key information from the received upgrade program data request frame, such as the total number of upgrade program packages, the software version number, the sequence number of the current transmission package, etc.
[0108] Next, you can check whether the software versions are consistent. If the software version number extracted in the request frame is consistent with the version number of the application currently running on the device, generate an "upgrade version error" reply frame and send it to the system, and end the process. If the version numbers are different, proceed to the next step.
[0109] Next, the upgrade status can be verified, for example, checking whether the extracted software version number is consistent with the version number stored in the global structure of the upgrade information, checking whether the total number of upgraded program packages extracted is consistent with the total number of packages stored in the global structure of the upgrade information, and checking whether the extracted current transmission package sequence number is consistent with the current number of packets to be transmitted recorded in the global structure of the upgrade information. If all of the above conditions are met, proceed to the next step; otherwise, generate an "other error" reply frame and send it to the system, and end the process.
[0110] Then, the program data can be written. The program data can be extracted from the request frame and written to the corresponding Flash memory address. The write position is determined by the current transmission packet sequence number, and the write length is the size of a packet of data.
[0111] Next, the data consistency can be verified. For example, the newly written program data can be read from the Flash memory and compared with the originally extracted data. If the data is consistent, it indicates that the write is successful and the next step is continued. If the data is inconsistent, a "Flash storage error" reply frame is generated and sent to the system, and the process ends.
[0112] Finally, the upgrade status can be updated and feedback can be given, the checksum of the current transmission packet can be calculated, and the result can be added to the Flash program checksum field in the upgrade information global structure; then the current number of packages to be upgraded in the upgrade information global structure can be increased by 1 to record the new upgrade progress; then the updated upgrade information global structure can be saved in the external ferroelectric memory; finally, a reply frame (including the program version to be upgraded, the total number of packages and the current number of packages to be upgraded) is generated and sent to the system, indicating that the transmission of this program data is successful and the process ends.
[0113] As an example only, an upgrade program data reply frame may be represented as:
[0114]
[0115] In some embodiments, the upgrade program end frame may include an upgrade program end request frame and an upgrade program end reply frame. The upgrade program end request frame is used to carry firmware version information, program checksum, and upgrade timestamp, and the upgrade program end request frame is used to carry result field, firmware version information, and program checksum.
[0116] As an example only, the format of the upgrade program end request frame may be represented as:
[0117]
[0118] As an example only, the format of the upgrade procedure end reply frame may be represented as:
[0119]
[0120]
[0121] In some embodiments, the parsing process of the upgrade program end reply frame is as follows:
[0122] First, the upgrade information can be extracted. The device can extract the following content from the received upgrade program end request frame: the checksum of the upgrade program, the software version number, and the time information of the upgrade completion, including year, month, day, hour, minute, and second.
[0123] Next, you can check whether the software version is consistent. If the extracted software version number is consistent with the APP program version number currently running on the device, generate an "upgrade version error" reply frame and send it to the system, and end the process. If the version number is different, proceed to the next step.
[0124] Next, the integrity of the upgrade program data can be verified by comparing the upgrade program checksum extracted from the request frame with the Flash program checksum stored in the upgrade information global structure: if they are inconsistent, a "checksum error" reply frame is generated and sent to the system, and the process ends; if they are consistent, it means that the program data is complete and correct, and proceed to the next step.
[0125] Finally, the upgrade status can be updated and the information can be stored. The software update flag in the global structure of the upgrade information can be set to 1, indicating that the upgrade has been completed. Then the upgrade completion time information (year, month, day, hour, minute, second) extracted from the request frame is assigned to the corresponding field in the global structure of the upgrade information. Then the updated global structure of the upgrade information is saved to the remote information storage area in the external ferroelectric memory; finally, a reply frame (including the program version to be upgraded, the total number of packages, and the current number of packages to be upgraded in the global structure of the upgrade information) is generated and sent to the system, indicating that the upgrade process has been successfully completed and the process ends.
[0126] In some embodiments, the method of the present application may further include:
[0127] First, verify the application upgrade conditions;
[0128] Next, if the application upgrade condition verification fails, the application upgrade preparation process is exited; if the application upgrade condition verification passes, the application upgrade time is determined according to the upgrade information;
[0129] Finally, if the format of the upgrade time is wrong, the upgrade preparation process is exited; if the upgrade time has been reached and the format of the upgrade time is correct, the remote upgrade flag is stored in the memory.
[0130] In the specific implementation, the device first checks whether the software update flag in the global structure is 1. If the flag is 0, it means there is no need for an upgrade, and the system will directly exit the current upgrade preparation process. If the flag is 1, it means there is a need for an upgrade, and the system continues to verify other conditions.
[0131] Next, the device can check whether the remote program checksum stored in the upgrade information is consistent with the program checksum in Flash, which is a flash memory. If the two are inconsistent, it means that there may be a problem with the program data and the upgrade cannot be performed. The system will exit the upgrade process.
[0132] In addition, the device needs to check that the remote program checksum is not 0, and the total number of packets plus 1 is equal to the number of packets currently required to be transmitted. If these two conditions are not met, it means that the order or content of the program package is incorrect, and the system will exit the process.
[0133] It is understandable that if the above check and verification fails (ie any one of the conditions is not met), the system will exit the application upgrade preparation process, indicating that the upgrade conditions are not met and subsequent upgrade operations will not continue.
[0134] Correspondingly, if the application upgrade condition verification passes, it will proceed to the next step to determine whether the upgrade can be performed based on the upgrade time in the global structure. The details are as follows:
[0135] First, check the format of the upgrade time. The device can check the upgrade year, month, day, hour, minute, and second fields in the global structure. If the fields are all 0, it means that no specific upgrade time is specified. At this time, the system will immediately perform the upgrade operation, update the upgrade flag to 1, indicating that the upgrade has started, and set the software update flag to 0, indicating that the upgrade preparation is complete. If the upgrade year, month, day, hour, minute, and second are not all 0, the device will proceed to the next step to check whether the current time has reached the specified upgrade time.
[0136] If the device finds that the upgrade time has been set (that is, the year-month-day hour-minute-second field is not 0), it can compare the current time with the upgrade time in the global structure. The specific operation is:
[0137] If the current time exceeds or is equal to the upgrade time set in the global structure, the device will set the upgrade flag to 1, indicating that the upgrade can be started. Set the software update flag to 0, indicating that the upgrade process is ready. Store the upgrade information in the remote information storage area of the external ferroelectric memory. Then, the device will perform a reset operation, restart the MCU, and start the upgrade. If the current time has not reached the specified upgrade time, the device believes that the upgrade time has not yet arrived, and the system will exit the upgrade preparation process without performing any upgrade operations.
[0138] In summary, the system of the present application first verifies whether the upgrade conditions are met, such as checksum consistency, packet number check, etc. If the conditions are not met, the upgrade process is exited. If the upgrade conditions are passed, the system will check the upgrade time and decide whether to upgrade immediately. Storage and reset operation of the upgrade flag: If the upgrade time is reached, the system will set the relevant flag and store it in the memory, then reset the MCU and start the upgrade. Ensure that the device is remotely upgraded only when all conditions are met, avoiding incorrect upgrade operations or time control errors.
[0139] Step 102: Read a remote upgrade flag from a first global variable for storing remote upgrade information according to the upgrade information of the application.
[0140] The first global variable can be a memory global structure variable used to manage and record remote upgrade related information during the upgrade process. It is the core of the entire remote upgrade process and is responsible for saving the dynamic state and key parameters during the upgrade process to ensure that the device can effectively execute, monitor and restore remote upgrade operations. Figure 2 As shown, in order to distinguish the first global variable from the second global variable, the first global variable may also be referred to as “global structure variable B”, and the second global variable may also be referred to as “global structure variable A”.
[0141] Just as an example, the data structure of the first global variable can be represented as:
[0142] typedef struct;
[0143] {
[0144] INT16_UpdateApp; / upgrade flag / ;
[0145] INT16U UpdateYear; / Update time-year / ;
[0146] INT16U UpdateMonth; / Update time-month / ;
[0147] INT16U UpdateDay; / Update time-day / ;
[0148] INT16U UpdateHour; / Update time-hour / ;
[0149] INT16U UpdateMinute; / Update time-minute / ;
[0150] INT16U UpdateSecond; / Update time - seconds / ;
[0151] INT16_UpdateFlag; / Software update flag / ;
[0152] INT16U Software; / release software version / ;
[0153] INT16U TotalPackage; / Total number of packages / ;
[0154] INT16U CurrentPackage; / Package number / ;
[0155] INT32U CloudProgramSum; / Download program checksum / ;
[0156] INT32U RealProgramSum; / Write program checksum in Flash / ;
[0157] INT16_CHECKCRC;
[0158] }TypeStr_CloudUpdatePara.
[0159] The remote upgrade flag is a key field in the first global variable, which is used to indicate whether the device is undergoing remote upgrade.
[0160] In some embodiments, the remote upgrade information may be first read from the remote upgrade information storage area of the ferroelectric memory into the first global variable, and then the value of the remote upgrade flag may be read from the first global variable.
[0161] Step 103: If the value of the remote upgrade flag is set to the first value, the remote upgrade storage processing flow is executed on the application; if the remote upgrade flag is set to the second value, the local upgrade flag is read from the second global variable used to store local upgrade information.
[0162] In some embodiments, the first value and the second value are used to distinguish the state of the remote upgrade flag. For example, the first value can be set to 1 and the second value can be set to 0. When the value of the remote upgrade flag is 1, it means that the application of the device has started remote upgrade, can be started or is in the upgrade process. Correspondingly, when the value of the remote upgrade flag is 0, it means that the remote upgrade of the application has not been started or has been completed.
[0163] In some embodiments, step 103 may include:
[0164] First, read the remote upgrade program of the application and the upgrade program package of the remote upgrade program;
[0165] Next, a first checksum is calculated based on the size of the upgrade program package;
[0166] Then, the first checksum is compared with the preset checksum. When the first checksum is equal to the preset checksum, the writing process of the remote upgrade program is executed; when the first checksum is not equal to the preset checksum, the process jumps to the check exception handling process;
[0167] Then, according to the written upgrade program package, a second checksum is calculated;
[0168] Finally, the second checksum is compared with the preset checksum. If the second checksum is equal to the preset checksum, a remote upgrade success flag is set; if the second checksum is not equal to the preset checksum, a remote upgrade failure flag is set.
[0169] like Figure 3 As shown, in a specific implementation, the remote upgrade program can first be read from the external Flash memory (i.e., the flash memory) in sub-packets, and the reading process is performed according to the total package size of the upgrade program stored in the second global variable. Each program package is read in turn as a basis for subsequent verification and writing. The first checksum Sum2 can be calculated based on the read upgrade program data to verify whether the read data is complete and correct.
[0170] In some embodiments, the calculated first checksum Sum2 can be compared with the preset checksum Sum1 in the second global variable: if they are equal, it means that the data stored in the external Flash is correct and the writing process begins; if they are not equal, jump to the check exception handling process and terminate the current upgrade operation.
[0171] After the verification is passed, the sub-package data can be written one by one from the external Flash to the AP P area of the internal Flash. After each write, the accuracy of the data write is ensured by comparing the read data with the written data. If the write is inconsistent, jump to the exception handling process; if it is consistent, continue to write the next sub-package until all program packages are written.
[0172] When all program packages are written, the written data can be read from the APP area, and the second checksum Sum3 is calculated according to the size of the upgrade program. The second checksum (Sum3) is then compared with the preset checksum (Sum1): if they are equal, it means that the upgrade program is written successfully, the remote upgrade success flag is set, and the process ends; if they are not equal, it means that the written data is incorrect, the remote upgrade failure flag is set, and the process ends.
[0173] It can be understood that in the above process, the first checksum is used to verify whether the read data is correct, which is the condition for entering the write process. The second checksum is used to verify whether the written data is complete and consistent with the preset, which is the basis for judging the success or failure of the upgrade. Exception handling means that when any step of the check fails, the process immediately jumps to the exception handling to ensure that the data is not used or overwritten by mistake; the success mark is to set the upgrade success mark after all checks are passed to ensure that the status of the upgrade result can be marked at the end of the process.
[0174] Through the above step-by-step verification and comparison method, the present application can ensure the reliability and integrity of the remote upgrade data, and reduce the risk of the device not being able to work properly due to data anomalies.
[0175] In some embodiments, the remote upgrade program can be written in the following ways:
[0176] First, the remote upgrade program is sequentially written into a preset storage area of the memory according to a preset sub-package size to obtain a plurality of program sub-packages;
[0177] Next, a data consistency check is performed on each program subpackage. If the check passes, the program subpackage is written into the memory. If the check fails, the process jumps to the check exception handling process.
[0178] In a specific implementation, according to this solution, the remote upgrade program can be divided into multiple program sub-packages, and the size of each sub-package is determined according to a preset sub-package size. After the sub-package data is read from the external Flash memory in sequence, it is written one by one into the preset storage area of the memory (such as the APP storage area of the internal Flash), ensuring that the upgrade data is divided and gradually loaded into the target storage area.
[0179] Before each program sub-package is written to the memory, the device will perform a data consistency check on the sub-package data to compare whether the read program sub-package data is consistent with the data read again after writing. The core of the check is to ensure that the program data is not damaged or lost during the storage process. If the data consistency check passes, it means that the current program sub-package data is correct and complete, and then continue to write the next program sub-package; if the data consistency check fails, it will immediately jump to the exception handling process to avoid system failure caused by erroneous data writing.
[0180] Through the above methods, this application can ensure the reliability of the remote upgrade program, and even in a complex network environment, it can effectively avoid data errors that may occur during the upgrade process through verification and exception handling mechanisms.
[0181] In some embodiments, the method of the present application may further include:
[0182] Get the loop variable i at the index position of the program subpackage being processed, and initialize the loop variable i to 0;
[0183] Write the i+1th program subpackage into the preset storage area and perform consistency check on the program subpackage;
[0184] When the program subpackage verification passes, the value of the loop variable i is increased by one unit; when the program subpackage verification fails, it jumps to the verification exception handling process;
[0185] It is determined whether the loop variable i is equal to the total number of program sub-packages. If not, the writing process of the next program sub-package is continued. If equal, the writing process of all program sub-packages is terminated.
[0186] like Figure 3As shown, based on the above content, the explanation is as follows: first, the index position of the program subpackage being processed, that is, the loop variable i, can be obtained, and its initial value is set to 0, indicating that the program subpackage currently being processed is the first subpackage (i+1).
[0187] In some embodiments, the data of the i+1th program subpackage can be written to a preset storage area, such as the APP area of the internal Flash memory. After writing is completed, a consistency check is performed on the subpackage data to ensure that the written data is consistent with the original data and complete. If the data verification of the current subpackage passes, it means that the subpackage data is successfully written, and the system increases the value of the loop variable i by 1 (i=i+1) to process the next subpackage; if the verification fails, it indicates that there is an exception in the current subpackage data, and the process immediately jumps to the verification exception handling process to prevent the continued transmission of erroneous data.
[0188] After each sub-package is processed, the system can determine whether the value of the loop variable i is equal to the total number of program sub-packages: if the loop variable i is less than the total number of sub-packages, it means that there are still sub-packages that have not been processed, and the system continues to execute the writing and verification process of the next sub-package; if the loop variable i is equal to the total number of sub-packages, it means that all sub-packages have been successfully written and the process ends.
[0189] In the above manner, the loop mechanism of the present application can effectively ensure the accurate writing of program sub-packaging and the integrity of upgrade data by gradually processing sub-packaging, dynamically updating loop variables and real-time verification.
[0190] In some embodiments, the method of the present application may further include:
[0191] First, obtain the application upgrade results;
[0192] Next, if the upgrade result is that the application upgrade is successful, the value of the remote upgrade flag or the value of the local upgrade flag is reset;
[0193] Finally, if the upgrade result is that the application upgrade fails, the upgrade process of the application is re-executed.
[0194] In the specific implementation, after the application is remotely upgraded or locally upgraded, it can be determined whether the remote upgrade or local upgrade updates the application storage area successfully. If the remote upgrade is successful, the remote upgrade flag is cleared and stored in the remote upgrade information area of the external ferroelectric; if the local upgrade is successful, the local upgrade flag is cleared and saved in the local upgrade information area of the external ferroelectric.
[0195] Correspondingly, if the upgrade result is that the application upgrade fails, the process directly jumps back to the first step of the application upgrade process and re-executes the entire upgrade process.
[0196] Step 104: If the value of the local upgrade flag is set to the first value, the local upgrade storage processing flow is executed on the application; if the value of the local upgrade flag is set to the second value, the application is started.
[0197] As mentioned above, when the value of the remote upgrade flag is 1, it means that the device's application has started remote upgrade, can currently be started or is in the upgrade process. Correspondingly, when the value of the remote upgrade flag is 0, it means that the remote upgrade of the application has not started or has been completed.
[0198] Here, the value setting rule of the local upgrade flag can be consistent with the remote upgrade flag. When the value of the local upgrade flag is read and is set to 1, it means that the application can be started or is in the upgrade process, and the local upgrade storage processing process is executed on the application. Correspondingly, when the value of the local upgrade flag is read and is set to the second value, it means that the remote upgrade of the application has not been started or has been completed, and the application can be started.
[0199] The embodiment of the present application supports the MCU system and uses simple variables to record and determine the breakpoint position, which greatly simplifies the operation of resuming data during the application upgrade process. During the entire upgrade process, only a fixed breakpoint position needs to be tracked, reducing the complexity of breakpoint search, thereby improving the efficiency of application upgrades.
[0200] In a possible example, in order to better implement the application program upgrade method in the embodiment of the present application, in addition to the application program upgrade method, the embodiment of the present application also provides an application program upgrade system. Figure 4 As shown, the system may include:
[0201] A microcontroller unit is used to execute the above-mentioned application program upgrade method. The microcontroller unit is divided into a boot program area and an application program area. The boot program area is used to update the upgrade information of the application program to the application program area and execute the jump operation of the application program. The application program area is used to run the application program and the upgrade program of the application program.
[0202] A flash memory, used for storing temporary remote upgrade information during the process of running the remote upgrade program in the application program area;
[0203] The ferroelectric memory includes a remote upgrade information storage area and a local upgrade information storage area, wherein the remote upgrade information storage area is used to store remote upgrade information, and the local upgrade information storage area is used to store local upgrade information;
[0204] Remote communication interface, used to transmit remote upgrade information;
[0205] Local serial port, used to transmit local upgrade information.
[0206] Specifically, a microcontroller unit (MCU) can be used to execute the application upgrade method of the present application. The microcontroller unit may include a boot program area (Boot program area) and an application program area (APP area). The boot program area updates the upgrade information and upgrade program from the external memory to the application program area, so that after the upgrade is completed, the boot program area jumps to the application program area to start the new version of the application program. The application program area is responsible for running the core functional program of the device, which is used to execute the upgrade program to ensure that the device can still maintain the operation of basic functions during the upgrade process.
[0207] Among them, the flash memory is Flash memory. When the remote upgrade program is running in the application area, the flash memory can be used to temporarily store the intermediate data and information generated during the remote upgrade process, such as the received program subpackaging data or checksum information, to provide reliable temporary storage space and ensure data integrity and recovery capabilities during the upgrade process.
[0208] Among them, ferroelectric memory is FRAM, which can be divided into two storage areas for storing persistent upgrade status information. The remote upgrade information storage area can be used to record key information such as the status, checksum, and number of subpackets during the remote upgrade process, and supports breakpoint resume function. The local upgrade information storage area can store local upgrade status information, such as local upgrade flags and current progress. Ferroelectric memory supports high-frequency write operations and can retain data after power failure, which is suitable for storing dynamic upgrade information.
[0209] The remote communication interface can be used for data transmission between the device and the remote upgrade management system. The interface receives upgrade request frames, upgrade data frames and end frames, and sends reply frames to complete the interactive process of remote upgrade.
[0210] The local serial port can be used to transmit upgrade data when the device is upgraded locally. For example, the device and the upgrade tool are directly connected via the serial port to receive local upgrade instructions and program packages, ensuring that the upgrade operation can be achieved even without a remote connection.
[0211] In a possible example, in order to better implement the application upgrade method in the embodiment of the present application, on top of the application upgrade method, the embodiment of the present application further provides an application upgrade device 200, such as Figure 5 As shown, the application program upgrade device 200 includes:
[0212] The data acquisition module 201 is used to acquire the upgrade information of the application; the upgrade information includes remote upgrade information and local upgrade information;
[0213] A flag identification module 202, used for reading a remote upgrade flag from a first global variable used for storing the remote upgrade information according to the upgrade information of the application program;
[0214] The remote upgrade module 203 is used to execute the remote upgrade storage processing flow for the application program if the value of the remote upgrade flag is set to a first value; and to read the local upgrade flag from a second global variable used to store the local upgrade information if the remote upgrade flag is set to a second value;
[0215] The local upgrade module 204 is configured to execute a local upgrade storage processing flow for the application program if the value of the local upgrade flag is set to a first value, and to start the application program if the value of the local upgrade flag is set to a second value.
[0216] In an embodiment of the present application, the data acquisition module 201, the logo recognition module 202, the remote upgrade module 203 and the local upgrade module 204 can be used to execute steps 101-104 of the aforementioned method embodiment respectively. For more detailed contents or specific implementation methods of each functional module, please refer to the description of the corresponding method steps, which will not be repeated here.
[0217] The application upgrade device 200 provided in the present application first obtains the upgrade information of the application through the data acquisition module 201; then, through the flag recognition module 202, reads the remote upgrade flag from the first global variable used to store the remote upgrade information according to the upgrade information of the application; then, through the remote upgrade module 203, if the value of the remote upgrade flag is set to the first value, the remote upgrade storage processing flow is executed on the application; if the remote upgrade flag is set to the second value, the local upgrade flag is read from the second global variable used to store the local upgrade information; finally, through the local upgrade module 204, if the value of the local upgrade flag is set to the first value, the local upgrade storage processing flow is executed on the application; if the value of the local upgrade flag is set to the second value, the application is started.
[0218] The present application also provides a computer device. Figure 6 , Figure 6 This is a basic structural block diagram of the computer device in this embodiment.
[0219] The computer device includes a memory 310 and a processor 320 that are connected to each other through a system bus. It should be noted that the figure only shows a computer device with components 310-320, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0220] Computer devices can be computing devices such as desktop computers, notebooks, PDAs, and cloud servers. Computer devices can interact with users through keyboards, mice, remote controls, touch pads, or voice control devices.
[0221] The memory 310 includes at least one type of readable storage medium, and the readable storage medium includes a non-volatile memory or a volatile memory, for example, a flash memory, a hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory, etc.), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc., and the RAM may include a static RAM or a dynamic RAM. In some embodiments, the memory 310 may be an internal storage unit of a computer device, for example, a hard disk or a memory of the computer device. In other embodiments, the memory 310 may also be an external storage device of a computer device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card or a flash card (Fla sh Card) equipped on the computer device. Of course, the memory 310 may also include both an internal storage unit of the computer device and its external storage device. In this embodiment, the memory 310 is generally used to store an operating system and various application software installed on the computer device, such as the program code of the above method. In addition, the memory 310 may also be used to temporarily store various types of data that have been output or are to be output. In some embodiments, the memory 310 may also be a register.
[0222] The processor 320 is generally used to perform the overall operation of the computer device. In this embodiment, the memory 310 is used to store program codes or instructions, the program code includes computer operation instructions, and the processor 320 is used to execute the program codes or instructions stored in the memory 310 or process data, such as running the program code of the above method.
[0223] In this article, the bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus system can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0224] Another embodiment of the present application also provides a computer-readable medium, which may be a computer-readable signal medium or a computer-readable medium. A processor in a computer reads a computer-readable program code stored in the computer-readable medium, so that the processor can execute the functional actions specified in each step or a combination of steps in the above method; and generate a device for implementing the functional actions specified in each block or a combination of blocks in the block diagram.
[0225] Computer-readable media include but are not limited to electronic, magnetic, optical, electromagnetic, infrared memory or semiconductor systems, devices or apparatuses, or any appropriate combination of the foregoing, the memory is used to store program codes or instructions, the program codes include computer operating instructions, and the processor is used to execute the program codes or instructions of the above methods stored in the memory.
[0226] For the definitions of memory and processor, please refer to the description of the aforementioned computer device embodiment and will not be repeated here.
[0227] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0228] Each functional unit or module in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0229] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program code.
[0230] In the claims, any reference symbols placed between brackets shall not be construed as limiting the claims. The word "comprising" described in the present application does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present application can be implemented with the aid of hardware comprising several different elements and with the aid of a suitably programmed computer. In a unit claim that lists a number of devices, several units of these devices may be embodied by the same hardware item. The use of first, second, and third, etc. does not indicate any order, and these words may be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be understood as limitations on the order of execution.
[0231] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for upgrading an application, characterized in that: The method comprises: Obtaining application upgrade information; the upgrade information includes remote upgrade information and local upgrade information; According to the upgrade information of the application, a remote upgrade flag is read from a first global variable used to store the remote upgrade information; If the value of the remote upgrade flag is set to a first value, a remote upgrade storage processing flow is executed on the application; if the remote upgrade flag is set to a second value, a local upgrade flag is read from a second global variable used to store the local upgrade information; If the value of the local upgrade flag is set to the first value, a local upgrade storage processing flow is executed on the application; if the value of the local upgrade flag is set to the second value, the application is started.
2. The application program upgrade method according to claim 1, characterized in that: After the remote upgrade storage processing flow of performing remote upgrade on the application, the process further includes: Obtaining an upgrade result of the application; If the upgrade result is that the application is successfully upgraded, resetting the value of the remote upgrade flag or the value of the local upgrade flag; If the upgrade result is that the application upgrade fails, the upgrade process of the application is re-executed.
3. The application program upgrade method according to claim 1, characterized in that: The remote upgrade storage processing flow for the application program includes: Reading the remote upgrade program of the application and the upgrade program package of the remote upgrade program; Calculate a first checksum according to the size of the upgrade program package; Compare the first checksum with the preset checksum, and when the first checksum is equal to the preset checksum, execute the writing process of the remote upgrade program; when the first checksum is not equal to the preset checksum, jump to the check exception handling process; Calculate and obtain a second checksum according to the written upgrade program package; The second checksum is compared with the preset checksum. If the second checksum is equal to the preset checksum, a remote upgrade success flag is set; if the second checksum is not equal to the preset checksum, a remote upgrade failure flag is set.
4. The application program upgrade method according to claim 3, characterized in that: The writing process of the remote upgrade program includes: Writing the remote upgrade program into a preset storage area of the memory in sequence according to the preset sub-package size to obtain a plurality of program sub-packages; A data consistency check is performed on each of the program subpackages. If the check passes, the program subpackage is written into the memory. If the check fails, the process jumps to the check exception handling process.
5. The application program upgrade method according to claim 4, characterized in that: The method further comprises: Obtaining a loop variable i at the index position of the program subpackage being processed, and initializing the loop variable i to 0; Writing the (i+1)th program subpackage into the preset storage area, and performing a consistency check on the program subpackage; When the program subpackage verification passes, the value of the loop variable i is increased by one unit; when the program subpackage verification fails, the process jumps to the verification exception handling process; It is determined whether the loop variable i is equal to the total number of program sub-packages. If not, the writing process of the next program sub-package is continued. If equal, the writing process of all program sub-packages is terminated.
6. The application program upgrade method according to claim 1, characterized in that: Before obtaining the upgrade information of the application, the method further includes: obtaining an upgrade frame carrying a data packet for remotely upgrading the application, and parsing the upgrade frame to obtain the upgrade information and upgrade flag of the application; The upgrade frame includes a registration frame, an upgrade program start frame, an upgrade program data frame and an upgrade program end frame, wherein: The registration frame includes a registration request frame and a registration reply frame, and the registration reply frame is used to carry program version information of the application and device type information of the device; The upgrade program start frame includes an upgrade program start request frame and an upgrade program start reply frame, wherein the upgrade program start request frame is used to carry firmware version information, the total number of program packages, program checksum, and a forced update flag; the upgrade program start reply frame is used to carry a result field, the total number of program packages, and a frame sequence number expected to be transmitted; The upgrade program data frame includes an upgrade program data request frame and an upgrade program data reply frame, wherein the upgrade program data request frame is used to carry the firmware version information, the total number of program packages, the current transmission package sequence number, and the program data packet, and the upgrade program data reply frame is used to carry the result field, the total number of program packages, and the frame sequence number of the expected transmission; The upgrade program end frame includes an upgrade program end request frame and an upgrade program end reply frame. The upgrade program end request frame is used to carry the firmware version information, the program checksum, and the upgrade timestamp. The upgrade program end request frame is used to carry the result field, the firmware version information, and the program checksum.
7. The application program upgrade method according to claim 1, characterized in that: Before obtaining the application upgrade information, it also includes: Verifying the upgrade conditions of the application; If the upgrade condition verification of the application fails, then exit the upgrade preparation process of the application; if the upgrade condition verification of the application passes, then determine the upgrade time of the application according to the upgrade information; If the format of the upgrade time is wrong, the upgrade preparation process is exited; if the upgrade time has been reached and the format of the upgrade time is correct, the remote upgrade flag is stored in the memory.
8. An application program upgrade device, characterized in that: The device comprises: A data acquisition module, used to acquire application upgrade information; the upgrade information includes remote upgrade information and local upgrade information; A flag identification module, used for reading a remote upgrade flag from a first global variable used for storing the remote upgrade information according to the upgrade information of the application program; A remote upgrade module, configured to execute a remote upgrade storage processing flow for the application program if the value of the remote upgrade flag is set to a first value; and to read a local upgrade flag from a second global variable for storing the local upgrade information if the remote upgrade flag is set to a second value; A local upgrade module is used to execute a local upgrade storage processing flow for the application if the value of the local upgrade flag is set to the first value; and to start the application if the value of the local upgrade flag is set to the second value.
9. An application upgrade system, characterized in that: The system comprises: A microcontroller unit, used to execute the method according to any one of claims 1 to 7, wherein the microcontroller unit is divided into a boot program area and an application program area, wherein the boot program area is used to update the upgrade information of the application program to the application program area and to execute a jump operation of the application program, and the application program area is used to run the application program and an upgrade program of the application program; A flash memory, used for storing temporary remote upgrade information during the process of running the remote upgrade program in the application program area; A ferroelectric memory, comprising a remote upgrade information storage area and a local upgrade information storage area, wherein the remote upgrade information storage area is used to store the remote upgrade information, and the local upgrade information storage area is used to store the local upgrade information; A remote communication interface, used for transmitting the remote upgrade information; The local serial port is used to transmit the local upgrade information.
10. The application program upgrade system according to claim 9, characterized in that: The microprocessor is also used for: Prioritize the execution of the program in the boot program area during reset, detect the remote upgrade flag and the local upgrade flag in turn, and obtain corresponding detection results; The remote upgrade storage processing flow of the remote upgrade mark or the local upgrade storage processing flow of the local upgrade mark is executed according to the detection result, and after the upgrade is completed, the application area is jumped to run the application.
11. A computer device, characterized in that: include: Processor and memory; The memory is used to store computer programs; The processor is used to execute the computer program stored in the memory to implement the steps of the application upgrade method described in any one of claims 1-7.
12. A computer-readable storage medium, characterized in that: A computer program is stored, and the computer program is loaded by a processor to execute the steps of the application program upgrading method described in any one of claims 1-7.