MCU upgrade method, MCU, storage medium

By monitoring and receiving upgrade commands and sub-files in the microcontroller, slicing, processing and verifying data, combined with configuration partition management, the problem of upgrade errors and transmission errors during the microcontroller upgrade process is solved, achieving remote upgrades and reducing maintenance costs.

CN112631628BActive Publication Date: 2024-09-20BANGYAN TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011442135.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-11
Publication Date
2024-09-20
Estimated Expiration
2040-12-11

AI Technical Summary

Technical Problem

The existing microcontroller program upgrade process lacks a reliable mechanism to prevent upgrade errors and transmission errors, and does not support remote upgrades, resulting in upgrade failures and high maintenance costs.

Method used

By monitoring and receiving the upgrade commands and sub-files of the serial port or network port, slicing, processing and verification are performed to ensure data reliability. On the basis of supporting remote upgrade, the verification information and configuration partition are used to manage the upgrade process to ensure data integrity. and correctness.

Benefits of technology

It effectively reduces upgrade errors and bit errors during transmission, supports remote upgrades, reduces maintenance costs, and improves the reliability and upgrade success rate of the microcontroller.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112631628B
    Figure CN112631628B
Patent Text Reader

Abstract

The present invention discloses a single-chip microcomputer upgrade method, a single-chip microcomputer, and a storage medium, wherein the single-chip microcomputer upgrade method includes monitoring and receiving an upgrade command and an upgrade subfile of a serial port or a network port, wherein the upgrade subfile is obtained by slicing the upgrade file, and the upgrade subfile includes first verification information; verifying the data of the upgrade subfile to obtain second verification information; when the first verification information and the second verification information are consistent, sending a success instruction to a host computer and storing the upgrade subfile in an upgrade program partition. The single-chip microcomputer upgrade method of the present invention can effectively reduce the problems of upgrade errors and bit errors during transmission, and supports remote upgrades.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of electronic technology, and in particular to a single-chip microcomputer upgrading method, a single-chip microcomputer, and a storage medium. Background Art

[0002] With the rapid development of science and technology today, electronic products have penetrated into people's daily lives and become an indispensable part of people. In the field of small intelligent management systems, many electronic products use single-chip microcomputers as the main control chips. In particular, single-chip microcomputers have the characteristics of high reliability, low power consumption, and low cost for long-term operation, which can meet low-level needs and are widely used in electronic products.

[0003] In the process of using the MCU, the MCU program needs to be constantly upgraded according to user needs. At present, the upgrade of the MCU program is usually based on IAP (In Application Programming) technology, which is directly written into the specified program code area. The upgrade process has no reliable mechanism to prevent the occurrence of problems such as upgrading the wrong program and bit errors in the transmission process, which often leads to the failure to work normally after the upgrade. In addition, the upgrade must be connected to the MCU on site through a PC with the help of a designated programmer, and remote upgrade is not supported. Summary of the invention

[0004] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention provides a single-chip microcomputer upgrade method, a single-chip microcomputer, and a storage medium, which can effectively reduce the problems of upgrade errors and bit errors in the transmission process, and support remote upgrade.

[0005] A single chip computer upgrade method according to a first aspect of the present invention includes:

[0006] Listening to and receiving an upgrade command and an upgrade subfile from a serial port or a network port, wherein the upgrade subfile is obtained by slicing the upgrade file, and the upgrade subfile includes first verification information;

[0007] Verifying the data of the upgrade sub-file to obtain second verification information;

[0008] When the first verification information is consistent with the second verification information, a success instruction is sent to the host computer and the upgrade sub-file is stored in the upgrade program partition.

[0009] The single-chip microcomputer upgrade method according to the embodiment of the present invention has at least the following beneficial effects: the host computer slices the upgrade file into several upgrade sub-files, and then sends each upgrade sub-file to the single-chip microcomputer. The single-chip microcomputer verifies each received upgrade sub-file to ensure that the data transmitted each time is reliable, thereby effectively reducing the occurrence of upgrade errors and bit errors in the transmission process.

[0010] According to some embodiments of the present invention, the further comprising:

[0011] Verifying the data of the upgrade program partition to obtain third verification information;

[0012] When the third verification information is consistent with the first verification information, the upgrade flag is modified to run, and the upgrade flag is written into the upgrade configuration partition.

[0013] According to some embodiments of the present invention, the upgrading method further comprises:

[0014] When the third verification information is inconsistent with the first verification information, the original upgrade sub-file is cleared, and the latest upgrade command and upgrade sub-file of the serial port or network port are continuously monitored and received.

[0015] According to some embodiments of the present invention, the upgrade method further comprises: when the first verification information and the second verification information are inconsistent, sending a retransmission request to a host computer;

[0016] When the number of times the host computer receives the retransmission request exceeds a preset retransmission threshold, an upgrade termination instruction is received, and the upgrade is terminated according to the upgrade termination instruction.

[0017] According to some embodiments of the present invention, the upgrading method further comprises:

[0018] Obtain an upgrade identifier from the upgrade configuration partition;

[0019] When the upgrade mark is an upgrade, and when the running program partition has the original program file, obtaining fourth verification information from the upgrade configuration partition;

[0020] If the fourth verification information is consistent with the third verification information, storing the original program file of the running program partition into the backup program partition;

[0021] After the backup program partition is successfully written with the original program file, the original program file in the running program partition is erased, and the upgrade sub-file is stored in the running program partition.

[0022] According to some embodiments of the present invention, the upgrade method further comprises: when the running program partition does not have the original program file, storing the upgrade sub-file in the running program partition.

[0023] According to some embodiments of the present invention, the upgrading method further comprises:

[0024] Verifying the data of the running program partition to obtain fifth verification information;

[0025] If the fifth verification information is consistent with the fourth verification information, the fifth verification information is modified to be stored in the upgrade configuration partition, and the upgrade flag is modified to run and written into the upgrade configuration partition.

[0026] According to some embodiments of the present invention, the upgrade method further comprises: when the upgrade fails, erasing the upgrade program files of the running program partition, and writing the original program files of the backup program partition to the running program partition.

[0027] The single chip computer according to the second aspect of the present invention includes:

[0028] at least one processor, and

[0029] a memory communicatively connected to the at least one processor; wherein,

[0030] The memory stores instructions, and the instructions are executed by the at least one processor, so that the at least one processor implements the single-chip microcomputer upgrading method described in any one of the embodiments of the first aspect when executing the instructions.

[0031] The single-chip microcomputer according to the embodiment of the present invention has at least the following beneficial effects: the host computer slices the upgrade file into several upgrade sub-files, and then sends each upgrade sub-file to the single-chip microcomputer. The single-chip microcomputer verifies each upgrade sub-file received to ensure that the data transmitted each time is reliable, thereby effectively reducing the occurrence of upgrade errors and bit errors in the transmission process, and supporting remote upgrades.

[0032] According to the computer-readable storage medium of the embodiment of the third aspect of the present invention, the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to execute the single-chip microcomputer upgrading method as described in any one of the embodiments of the first aspect.

[0033] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] The present invention will be further described below with reference to the accompanying drawings and embodiments, wherein:

[0035] Figure 1 A flow chart of a single chip microcomputer upgrading method provided by an embodiment of the present invention;

[0036] Figure 2 A flow chart of a single chip microcomputer upgrading method provided by an embodiment of the present invention;

[0037] Figure 3 A flow chart of a single chip microcomputer upgrading method provided by an embodiment of the present invention;

[0038] Figure 4 The present invention provides a flowchart of a single chip microcomputer upgrade method. DETAILED DESCRIPTION

[0039] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.

[0040] In the description of the present invention, it should be understood that descriptions involving orientations, such as up, down, front, back, left, right, etc., and orientations or positional relationships indicated are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present invention.

[0041] In the description of the present invention, "several" means more than one, "many" means more than two, "greater than", "less than", "exceed", etc. are understood to exclude the number itself, and "above", "below", "within", etc. are understood to include the number itself. If there is a description of "first" or "second", it is only used for the purpose of distinguishing the technical features, and cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.

[0042] In the description of the present invention, unless otherwise clearly defined, terms such as setting, installing, connecting, etc. should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in the present invention based on the specific content of the technical solution.

[0043] In the description of the present invention, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0044] Here, concepts that may be involved in the embodiments of the present invention are first described.

[0045] The user program code storage area of ​​the microcontroller is pre-divided into five storage partitions, as follows:

[0046] The first partition is a read-only storage boot program partition, referred to as the boot program partition;

[0047] The second partition is a readable and writable storage running program partition, referred to as the running program partition;

[0048] The third partition is a readable and writable storage backup program partition, referred to as the backup program partition;

[0049] The fourth partition is a readable and writable storage upgrade program partition, referred to as the upgrade program partition;

[0050] The fifth partition is a readable and writable storage upgrade configuration partition, referred to as the upgrade configuration partition;

[0051] The upgrade configuration partition saves the parameters during the upgrade process: upgrade status (upgrade identification), running program CRC, backup program CRC, upgrade program CRC, program upgrade overwrite retry preset value, and upgrade status waiting data time preset value.

[0052] The upgrade status is divided into running and upgrading. When the upgrade status is upgrading, it means that the upgrade program partition has data and the running program partition needs to be upgraded; when the upgrade status is running, it means that the user program can be run directly without upgrading.

[0053] Cyclic Redundancy Check (CRC): It is calculated by performing a cyclic redundancy check algorithm on two files. After receiving the upgrade file, the microcontroller can use this CRC code to verify the integrity of the upgrade file to prevent errors in the transmission process from causing file damage. In this application, the public cyclic redundancy check CRC32 algorithm is used. CRC32 has extremely strong error detection capabilities and low overhead, and is suitable for microcontrollers with weak computing power to perform error detection on data.

[0054] Program type: It is used to identify the uniqueness of the current program application. When generating an application program, the program type must also be compiled into the built-in code. Based on the program type, it can be confirmed whether it is the upgrade program of this product, thereby avoiding miswriting operations.

[0055] The verification information (the first verification information to the fifth verification information are collectively referred to as verification information) includes but is not limited to: program type and CRC.

[0056] The microcontroller program protocol format structure includes: start header, command word, status, length, data, and check code. Among them:

[0057] Start header: fixed to two bytes 0xA5 and 0x5A, used to quickly find the message header;

[0058] Command word: 1 byte, used to execute command agreements between the host computer and the MCU, including upgrade startup, file transfer in progress, and file transfer completion;

[0059] Status: MCU returns the message processing status;

[0060] Length: indicates the length of data content;

[0061] Data: fill in the message content, such as upgrade file slice data (upgrade sub-file), etc.

[0062] Verification code: All message data is calculated through the cyclic redundancy check algorithm to obtain CRC32, and then the lowest 1 byte is taken.

[0063] Reference Figure 1 In a first aspect, some embodiments of the present invention provide a method for upgrading a single-chip microcomputer, including but not limited to step S110, step S120, and step S130.

[0064] Step S110: monitoring and receiving an upgrade command and an upgrade sub-file from a serial port or an Internet port, wherein the upgrade sub-file is obtained by slicing the upgrade file, and the upgrade sub-file includes first verification information;

[0065] Step S120: verifying the data of the upgrade sub-file to obtain second verification information;

[0066] Step S130: When the first verification information and the second verification information are consistent, a success instruction is sent to the host computer and the upgrade sub-file is stored in the upgrade program partition.

[0067] In step S110, the host computer first slices the upgrade file to obtain several upgrade sub-files. After each upgrade sub-file is sent and receives a successful response, the next upgrade sub-file is sent until all upgrade files are sent. In addition, each upgrade sub-file carries the first verification information to reduce the occurrence of bit errors during the transmission process and prevent upgrade failures due to transmission problems.

[0068] In step S120, the single chip microcomputer performs data verification on each received upgrade sub-file to obtain second verification information. If the verification is successful, a success response message is returned; if the verification fails, a retransmission request message is returned. By performing data verification on each received upgrade sub-file, the reliability of the data transmitted each time is ensured.

[0069] In step S130, the first verification information and the second verification information are compared. If the two are consistent, it means that there is no transmission error in the updated sub-files transmitted this time, and the updated sub-files transmitted this time are stored in the updated program partition. If all updated sub-files are correct, it means that there is no problem in the transmission process.

[0070] Through step S110, step S120, and step S130, the present application can effectively reduce the problems of upgrade errors and bit errors in the transmission process, and setting the network port can support remote upgrades.

[0071] Reference Figure 2 In some embodiments of the present invention, the single chip computer upgrade method includes but is not limited to: step S210 and step S220.

[0072] Step S210: verifying the data of the upgrade program partition to obtain third verification information;

[0073] Step S220: When the third verification information is consistent with the first verification information, the upgrade flag is modified to run, and the upgrade flag is written into the upgrade configuration partition.

[0074] In step S210, the single chip microcomputer verifies the upgrade file formed by integrating the upgrade sub-files written in step S230 to ensure that no error code or other problems occur during the writing process.

[0075] In step S220, the first verification information and the third verification information are compared. If the two are consistent, it means that no error occurs in the process of writing the upgrade sub-file, storing the upgrade program partition and integrating into the upgrade file, and the upgrade flag is changed to running.

[0076] In some embodiments of the present invention, the single chip microcomputer upgrade method further includes: when the third verification information is inconsistent with the first verification information, clearing the original upgrade sub-file, and continuing to monitor and receive the latest upgrade command and upgrade sub-file from the serial port or network port.

[0077] Specifically, in this embodiment, if the third verification information is inconsistent with the first verification information, it means that there is an error in writing or storing the upgrade program partition or an error in integrating into the upgrade file. In this case, the microcontroller will clear the internally stored upgrade sub-file to ensure that no upgrade error occurs, and continue to wait for new upgrade commands and upgrade sub-files.

[0078] Reference Figure 3 In some embodiments of the present invention, the single chip computer upgrade method further includes but is not limited to step S310 and step S320.

[0079] Step S310: When the first verification information and the second verification information are inconsistent, a retransmission request is sent to the host computer;

[0080] Step S320: When the number of times the host computer receives the retransmission request exceeds a preset retransmission threshold, it receives an upgrade termination instruction and terminates the upgrade according to the upgrade termination instruction.

[0081] Specifically, in this embodiment, if the first verification information and the second verification information are inconsistent, it means that an error occurred during the transmission of the upgrade file. In this case, the single-chip microcomputer sends a retransmission request to the host computer. After receiving the retransmission request, the host computer resends the upgrade sub-file to the single-chip microcomputer. When the number of retransmissions exceeds the preset retransmission threshold (such as 3 times), it means that other errors may occur, such as: an error occurred during slicing of the upgrade file. In this case, the host computer will send an end upgrade instruction to the single-chip microcomputer, and the single-chip microcomputer will end the upgrade according to the end upgrade instruction. This can prevent the single-chip microcomputer and the host computer from being stuck in the transmission process and reduce maintenance costs.

[0082] It is understandable that if the host computer does not receive a response command within a certain period of time, it will also resend the current upgrade sub-file and other information, and this should also be attributed to the number of retransmissions.

[0083] Reference Figure 4 In some embodiments of the present invention, the single chip computer upgrade method includes but is not limited to step S410, step S420, step S430, and step S440.

[0084] Step S410: Obtain an upgrade identifier from the upgrade configuration partition;

[0085] Step S420: when the upgrade mark is upgrade, and when the running program partition has the original program file, obtain fourth verification information from the upgrade configuration partition;

[0086] Step S430: if the fourth verification information is consistent with the third verification information, the original program file of the running program partition is stored in the backup program partition;

[0087] Step S440: After the original program file is successfully written into the backup program partition, the original program file in the running program partition is erased, and the upgrade sub-file is stored in the running program partition.

[0088] Specifically, in the present embodiment, when the upgrade mark is upgraded, it indicates that there is upgrade data in the upgrade program partition. In this case, when there is also upgrade data (original program file) in the running program partition, the fourth verification information and the third verification information are compared. By comparing the two verification information, it is possible to determine whether the upgrade data of the upgrade program partition can be executed locally or whether the type is consistent with the original program file, etc. When the two are consistent, the upgrade data of the running program partition is first stored in the backup program partition for data backup. When the backup program partition is successfully written to the original program file, the original program file in the running program partition is erased, and the upgrade data (this upgrade subfile) in the upgrade program partition is stored in the running program partition. By setting it in this way, the probability of successful upgrade can be further enhanced, and at the same time, a fallback for upgrade errors is also provided.

[0089] In some embodiments of the present invention, the single chip computer upgrade method further includes but is not limited to step S510.

[0090] Step S510: When the running program partition does not have the original program file, the upgrade sub-file is stored in the running program partition.

[0091] In this embodiment, when the running program partition does not have the original program file, it means that this upgrade may be the first write. In this case, directly writing the upgrade data (upgrade sub-file) of the upgrade program partition and storing it in the running program partition can avoid the subsequent judgment and erasure process and improve work efficiency.

[0092] In some embodiments of the present invention, the single chip computer upgrade method further includes but is not limited to step S610.

[0093] Step S610: verifying the data of the running program partition to obtain fifth verification information;

[0094] If the fifth verification information is consistent with the fourth verification information, the fifth verification information is stored in the upgrade configuration partition, and the upgrade flag is modified to run and written into the upgrade configuration partition.

[0095] Specifically, in this embodiment, after the upgrade data (upgrade sub-file) is written into the running program partition, the data of the running program partition is verified to obtain the fifth verification information, and the fifth verification information is compared with the fourth verification information. If the two are consistent, it means that there is no error in the writing process and the upgrade data can also be run locally. In this case, the fourth verification information is updated to the fifth verification information so that it can be read directly from the upgrade configuration partition next time. At the same time, the upgrade flag is changed to running, waiting for upgrade.

[0096] In some embodiments of the present invention, the single chip computer upgrade method further includes: when the upgrade fails, erasing the upgrade program file of the running program partition, and writing the original program file of the backup program partition to the running program partition.

[0097] This setting is equivalent to rolling back the version of the microcontroller to solve the problem of the microcontroller not working due to an upgrade error.

[0098] The following describes in detail the single chip computer upgrade method of the embodiment of the present invention with a specific embodiment. It is worth understanding that the following description is only an exemplary description, and is not a specific limitation of the present invention.

[0099] The user program code storage area of ​​the microcontroller is pre-divided into five storage partitions, as follows:

[0100] The first partition is a read-only storage boot program partition, referred to as the boot program partition;

[0101] The second partition is a readable and writable storage running program partition, referred to as the running program partition;

[0102] The third partition is a readable and writable storage backup program partition, referred to as the backup program partition;

[0103] The fourth partition is a readable and writable storage upgrade program partition, referred to as the upgrade program partition;

[0104] The fifth partition is a readable and writable storage upgrade configuration partition, referred to as the upgrade configuration partition;

[0105] The upgrade configuration partition saves the parameters during the upgrade process: upgrade status (upgrade identification), running program CRC, backup program CRC, upgrade program CRC, program upgrade overwrite retry preset value, and upgrade status waiting data time preset value.

[0106] To prevent upgrade errors, add the following information to the header of the binary file: program type and CRC.

[0107] Processing of upgrade files:

[0108] 1. Regulation: Each message request from the host computer must wait for a response message.

[0109] 2. Before sending the file, the host computer sends the upgrade start message. After the MCU responds successfully, the host computer slices the upgrade file to obtain several upgrade sub-files, each of which is up to 240 bytes. After each upgrade sub-file is sent and receives a successful response, the index is increased by 1 and then the next upgrade sub-file is sent. After all data is sent, the file end message is sent. If the host computer waits for more than the preset timeout (default 500 milliseconds) or the MCU responds to a request for retransmission, the host computer retransmits the current frame message. If the number of retransmissions is greater than the preset number of retries (default 3 times), the upgrade is terminated.

[0110] 3. After receiving the upgrade start message, the MCU enters the upgrade program state to prepare to receive files and responds to the upgrade start success message. The MCU must verify the data after receiving each message to ensure that the data transmitted each time is reliable. If the verification is successful, a successful response message is returned. If the verification fails, a request for retransmission is returned.

[0111] 4. After the MCU enters the upgrade program state, it starts the data receiving timeout count. When the cumulative number of times exceeds the preset number (the default is 3 times) without receiving any data, the current upgrade will end automatically. Each time a frame of data is received, the timeout count will be cleared to 0. After the file is received, the upgrade file data CRC is calculated to see if it is consistent with the file header CRC. If the two are consistent, the file transfer is successful, otherwise it fails.

[0112] Upgrade process:

[0113] Step 1: After the MCU starts, run the boot program first, read the upgrade flag from the upgrade configuration partition, if it is an upgrade, jump to step 2, otherwise jump to step 5;

[0114] Step 2: Calculate the upgrade program partition data CRC, and read the upgrade program CRC record from the upgrade configuration partition. If the two are consistent, jump to step 3; otherwise, change the upgrade flag to run and write it to the upgrade configuration partition, and jump to step 5;

[0115] Step 3: Erase the backup program partition, write the running program partition data to the backup program partition, calculate the backup program partition data CRC, and read the backup program CRC record from the upgrade configuration partition. If the two are consistent, write the backup program partition CRC to the upgrade configuration partition and jump to step 4. Otherwise, repeat step 3. If the number of times this step is executed is greater than the preset number (the default is 3 times), jump to step 4.

[0116] Step 4: Erase the original program data of the running program partition, write the upgrade program partition data to the running program partition, calculate the running program partition data CRC, and read the upgrade program CRC record from the upgrade configuration partition. If the two are consistent, write the running program partition CRC to the upgrade configuration partition, change the upgrade flag to running and write to the upgrade configuration partition, and jump to step 5. Otherwise, repeat step 4. If the number of executions of this step is greater than the preset number (the default is 3 times), jump to step 5.

[0117] Step 5: Determine whether there is data in the partition for running the program. If there is data, jump to the partition for running the program and run the program, then jump to step 7. If there is no data, then jump to step 6.

[0118] Step 6: Enter the serial port upgrade mode, wait for the upgrade command, receive data and write it into the upgrade program partition. After receiving, determine whether the calculated upgrade program partition data CRC is consistent with the received CRC, and whether the program type is consistent. If both are consistent, change the upgrade flag to run and write it into the upgrade configuration partition. If one of them is inconsistent, clear the relevant parameters and repeat step 6.

[0119] Step 7: After running the application, start the serial port or network port to wait for the upgrade program command. If the upgrade program command is received, enter the process of receiving the upgrade file and write the file data into the upgrade program partition. After receiving, determine whether the calculated upgrade program partition data CRC is consistent with the received CRC and whether the program type is consistent. If both are consistent, modify the upgrade flag to run and write the upgrade configuration partition. If one of them is inconsistent, clear the relevant parameters and repeat step 7.

[0120] The microcontroller upgrade method of the present application can prevent upgrade errors, reduce code errors during transmission and upgrade data writing failures, and at the same time, set up a backup program partition to implement the rollback function of the microcontroller, reduce the maintenance cost of the microcontroller, and support remote upgrades.

[0121] In the second aspect, an embodiment of the present application also provides a single-chip microcomputer, comprising: at least one processor, and a memory communicatively connected to the at least one processor; wherein the memory stores instructions, and the instructions are executed by at least one processor so that when the at least one processor executes the instructions, a single-chip microcomputer upgrade method as described in any one of the embodiments of the first aspect is implemented.

[0122] The host computer slices the upgrade file into several upgrade sub-files, and then sends each upgrade sub-file to the MCU. The MCU verifies each upgrade sub-file received to ensure that the data transmitted each time is reliable, thereby effectively reducing upgrade errors and bit errors during the transmission process, and supports remote upgrades.

[0123] In a third aspect, embodiments of the present application also provide a computer-readable storage medium.

[0124] In some embodiments, a computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to execute the single-chip microcomputer upgrading method mentioned in the embodiment of the first aspect.

[0125] In some embodiments, the storage medium stores computer executable instructions, which are executed by one or more control processors, for example, by a processor in the above-mentioned electronic device, so that the above-mentioned one or more processors can execute the above-mentioned single-chip microcomputer upgrading method.

[0126] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0127] It will be appreciated by those skilled in the art that all or some of the steps and systems in the disclosed method above may be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that may be used to store desired information and may be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically embodies computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0128] The embodiments of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above embodiments. Various changes can be made within the knowledge of ordinary technicians in the relevant technical field without departing from the purpose of the present invention. In addition, the embodiments of the present invention and the features in the embodiments can be combined with each other without conflict.

Claims

1. A single chip microcomputer upgrading method, characterized in that: include: Listening to and receiving an upgrade command and an upgrade subfile from a serial port or a network port, wherein the upgrade subfile is obtained by slicing the upgrade file, and the upgrade subfile includes first verification information; Verifying the data of the upgrade sub-file to obtain second verification information; When the first verification information and the second verification information are consistent, a success instruction is sent to the host computer and the upgrade sub-file is stored in the upgrade program partition; Verifying the data of the upgrade program partition to obtain third verification information; When the third verification information is consistent with the first verification information, modify the upgrade flag to upgrade, and write the upgrade flag into the upgrade configuration partition; When the third verification information is inconsistent with the first verification information, clear the original upgrade sub-file, and continue to monitor and receive the latest upgrade command and upgrade sub-file of the serial port or network port; Get the upgrade identifier from the upgrade configuration partition; When the upgrade mark is an upgrade, and when the running program partition has the original program file, obtaining fourth verification information from the upgrade configuration partition; If the fourth verification information is consistent with the third verification information, the original program file of the running program partition is stored in the backup program partition; wherein the consistency of the fourth verification information and the third verification information indicates that the upgrade sub-file can be executed locally, and the upgrade sub-file is consistent with the original program file type; After the backup program partition is successfully written into the original program file, the original program file in the running program partition is erased, and the upgrade sub-file is stored in the running program partition; Verifying the data of the running program partition to obtain fifth verification information; If the fifth verification information is consistent with the fourth verification information, the fourth verification information is updated to the fifth verification information and stored in the upgrade configuration partition, and the upgrade flag is modified to run and written into the upgrade configuration partition; wherein, the upgrade status includes running and upgrading. When the upgrade status is upgrading, it indicates that the upgrade program partition has data and the running program partition needs to be upgraded. When the upgrade status is running, it indicates that the user program can be directly run without upgrading.

2. The upgrading method according to claim 1, characterized in that: The upgrade method further includes: when the first verification information and the second verification information are inconsistent, sending a retransmission request to a host computer; When the number of times the host computer receives the retransmission request exceeds a preset retransmission threshold, an upgrade termination instruction is received, and the upgrade is terminated according to the upgrade termination instruction.

3. The upgrading method according to claim 1, characterized in that: The upgrade method further includes: when the running program partition does not have the original program file, storing the upgrade sub-file in the running program partition.

4. The upgrading method according to claim 1, characterized in that: The upgrade method further includes: when the upgrade fails, erasing the upgrade program file of the running program partition, and writing the original program file of the backup program partition into the running program partition.

5. A single chip microcomputer, characterized in that: include: at least one processor, and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions, and the instructions are executed by the at least one processor, so that the at least one processor implements the single-chip computer upgrade method according to any one of claims 1 to 4 when executing the instructions.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to execute the single-chip microcomputer upgrading method according to any one of claims 1 to 4.