CN117908910A - MCU upgrading method and device, electronic equipment and storage medium - Google Patents

MCU upgrading method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117908910A
CN117908910A CN202211236874.8A CN202211236874A CN117908910A CN 117908910 A CN117908910 A CN 117908910A CN 202211236874 A CN202211236874 A CN 202211236874A CN 117908910 A CN117908910 A CN 117908910A
Authority
CN
China
Prior art keywords
file
upgraded
mcu
upgrade
upper computer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211236874.8A
Other languages
Chinese (zh)
Inventor
胡金龙
施璐
李番军
姚斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Pylon Technologies Co Ltd
Original Assignee
Pylon Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Pylon Technologies Co Ltd filed Critical Pylon Technologies Co Ltd
Priority to CN202211236874.8A priority Critical patent/CN117908910A/en
Publication of CN117908910A publication Critical patent/CN117908910A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1004Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Quality & Reliability (AREA)
  • Stored Programmes (AREA)

Abstract

The application relates to the technical field of program upgrading, in particular to a method, a device, electronic equipment and a storage medium for upgrading an MCU, wherein an upgrade source file is added with CRC (cyclic redundancy check) codes at designated positions to form a file to be upgraded, and then the file to be upgraded is sent to the MCU by an upper computer, wherein in the data transmission process, the data of each data packet of the received file to be upgraded are checked, and after the data of all the data packets are received, CRC (cyclic redundancy check) is carried out on the received whole file to be upgraded, so that the correct integrity of the data in the transmission process is ensured, and the phenomenon that the MCU cannot be used after the upgrade is finished due to the fact that the upper computer analyzes the upgrade source file error or the selected file to be upgraded is avoided; and when the file to be upgraded is not completely received, the file to be upgraded is temporarily stored in an external flash memory, so that the problem that the MCU cannot operate due to transmission interruption is avoided.

Description

MCU upgrading method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of program upgrade technologies, and in particular, to an MCU upgrade method, device, electronic apparatus, and storage medium.
Background
MCU (Microcontroller Unit, micro control unit), also called single chip microcomputer or single chip microcomputer, is to reduce the frequency and specification of CPU (Central Process Unit, central processing unit) properly, and integrate the peripheral interfaces such as memory, counter, USB, A/D conversion, UART, PLC, DMA, etc., even LCD driving circuit on A single chip to form A chip level computer for different application occasions to control different combinations. In order to improve the performance of the MCU, the MCU is often upgraded.
In the prior art, when the MCU is upgraded, only the data packets in the transmission process are accumulated and checked or CRC checked, and the MCU program is upgraded after the data packets are checked correctly. However, if the upper computer analyzes the bin source file error or selects the wrong upgrade bin file, the MCU cannot distinguish the upgrade file error only by checking whether the data packet is correct during transmission, and the upgrade cannot be operated after the upgrade is completed.
Disclosure of Invention
In order to overcome the defects in the prior art, the application provides an MCU upgrading method, an MCU upgrading device, electronic equipment and a storage medium, and the problem of error of a file to be upgraded issued by an upper computer during MCU upgrading can be avoided by performing CRC (cyclic redundancy check) on the whole received file to be upgraded.
In a first aspect, the present application provides a method for upgrading an MCU, the method comprising the steps of:
responding to an upgrade instruction sent by the upper computer, modifying an upgrade flag bit of the MCU into an upgrade state, and restarting the MCU;
Responding to the operation that the MCU reads the upgrading flag bit to be in an upgrading state, and receiving a file to be upgraded sent by an upper computer;
After the data of the file to be upgraded sent by the upper computer is completely received, calculating a check code of the received file to be upgraded, and comparing the CRC check code of the received file to be upgraded with the CRC check code of the file to be upgraded; if the received CRC check code of the file to be upgraded is consistent with the CRC check code of the file to be upgraded, modifying the upgrade flag bit of the MCU to be in an upgrade success state, and restarting the MCU;
And responding to the operation that the MCU reads the upgrade flag bit to be in an upgrade success state, and running the received file to be upgraded by the MCU.
In one possible implementation manner, before the response to the upgrade instruction sent by the upper computer, the method further includes the following steps:
calculating CRC check codes of the upgrade source files;
and placing the CRC code at the appointed position of the upgrading source file to obtain a file to be upgraded.
In one possible implementation manner, the method for receiving the data of the file to be upgraded sent by the upper computer comprises the following steps:
Receiving data packets of files to be upgraded sent by an upper computer one by one; wherein, the file to be upgraded at least consists of one data packet;
Checking each data packet of the file to be upgraded sent by the upper computer; if the verification is correct, feedback information for verifying the correctness is sent to the upper computer, so that the upper computer continues to send the next data packet; if the data packet is checked to be wrong, feedback information of the checking error is sent to the upper computer, so that the upper computer resends the data packet.
In a possible implementation manner, the verification of each data packet of the file to be upgraded sent by the received upper computer further includes the following steps:
Storing the data of the data packet which is checked to be correct into an external memory;
And storing the data of all the data packets with correct verification into an external memory to obtain a file to be upgraded sent by the upper computer.
In one possible implementation manner, the method for checking each data packet of the file to be upgraded sent by the received upper computer includes parity check, accumulation and check or CRC check.
In a possible implementation manner, the method for modifying the upgrade flag bit of the MCU to be in an upgrade success state, and before restarting the MCU, further includes the following steps:
and transferring the file to be upgraded in the external memory to the MCU.
In one possible implementation manner, the comparing the received CRC check code of the file to be upgraded with the CRC check code of the file to be upgraded further includes the following steps:
If the received CRC check code of the file to be upgraded is inconsistent with the CRC check code of the file to be upgraded, modifying the upgrade flag bit of the MCU into an upgrade failure state, and restarting the MCU;
And responding to the operation that the MCU reads the upgrade flag bit to be in an upgrade failure state, and running a program before upgrade by the MCU.
In a second aspect, the present application provides an MCU upgrade apparatus, the apparatus comprising:
The modification module is used for responding to an upgrade instruction sent by the upper computer, modifying an upgrade flag bit of the MCU into an upgrade state and restarting the MCU;
the receiving module is used for responding to the operation that the MCU reads the upgrading flag bit to be in an upgrading state and receiving a file to be upgraded sent by the upper computer;
The checking module is used for calculating a check code of the received file to be upgraded after the data of the file to be upgraded sent by the upper computer is completely received, and comparing the CRC check code of the received file to be upgraded with the CRC check code of the file to be upgraded; if the received CRC check code of the file to be upgraded is consistent with the CRC check code of the file to be upgraded, modifying the upgrade flag bit of the MCU to be in an upgrade success state, and restarting the MCU;
And the running module is used for responding to the operation that the MCU reads the upgrading flag bit to be in an upgrading success state, and the MCU runs the received file to be upgraded.
In a third aspect, the present application provides an electronic device comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory in communication via the bus when the electronic device is running, the machine-readable instructions when executed by the processor performing the steps of the MCU upgrade method of any of the first aspects.
In a fourth aspect, the present application provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the MCU upgrade method according to any of the first aspects.
In the MCU upgrading method, device, electronic equipment and storage medium provided by the embodiment, an upgrading flag bit of the MCU is modified to be in an upgrading state in response to an upgrading instruction sent by an upper computer, and the MCU is restarted; responding to the operation that the MCU reads the upgrading flag bit to be in an upgrading state, and receiving a file to be upgraded sent by an upper computer; after the data of the file to be upgraded sent by the upper computer is completely received, calculating a check code of the received file to be upgraded, and comparing the CRC check code of the received file to be upgraded with the CRC check code of the file to be upgraded; if the received CRC check code of the file to be upgraded is consistent with the CRC check code of the file to be upgraded, modifying the upgrade flag bit of the MCU to be in an upgrade success state, and restarting the MCU; and responding to the operation that the MCU reads the upgrade flag bit to be in an upgrade success state, and running the received file to be upgraded by the MCU. And the CRC check is carried out on the whole received file to be upgraded, so that the phenomenon that the MCU cannot be used after the upgrade is finished due to the error of the file to be upgraded issued by the upper computer during the MCU upgrade can be avoided.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of an MCU upgrade method according to an embodiment of the present application;
FIG. 2 is a flow chart illustrating the generation of a file to be upgraded according to an embodiment of the present application;
Fig. 3 is a flowchart illustrating a method for receiving a file to be upgraded sent by an upper computer according to an embodiment of the present application;
FIG. 4 is a block diagram illustrating an MCU upgrade apparatus according to an embodiment of the present application;
fig. 5 shows a block diagram illustrating a configuration of an electronic device according to an embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present application, and it should be understood that the drawings in the present application are for the purpose of illustration and description only and are not intended to limit the scope of the present application. In addition, it should be understood that the schematic drawings are not drawn to scale. A flowchart, as used in this disclosure, illustrates operations implemented according to some embodiments of the present application. It should be understood that the operations of the flow diagrams may be implemented out of order and that steps without logical context may be performed in reverse order or concurrently. Moreover, one or more other operations may be added to or removed from the flow diagrams by those skilled in the art under the direction of the present disclosure.
In addition, the described embodiments are only some, but not all, embodiments of the application. The components of the embodiments of the present application generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the application, as presented in the figures, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by a person skilled in the art without making any inventive effort, are intended to be within the scope of the present application.
It should be noted that the term "comprising" will be used in embodiments of the application to indicate the presence of the features stated hereafter, but not to exclude the addition of other features.
The MCU is used as a core component of the communication equipment, and in the upgrading process, two modes are generally adopted, one mode is to directly upgrade the MCU by adopting a special burning tool, but the mode needs to take the MCU out of the communication equipment and then burn and upgrade the MCU, so that the upgrading efficiency is lower; therefore, the MCU in the communication equipment is often upgraded in a second mode, namely, an upgrade program is downloaded to the MCU from an upper computer or a cloud through a transmission module, and remote online upgrade is performed, so that the upgrade efficiency of the MCU is improved. However, in the remote online upgrade mode, the phenomenon that the upgrade cannot be operated after the upgrade is completed often occurs, which is caused by the error of the upgrade program downloaded from the upper computer or the cloud. Based on the method, the device, the electronic equipment and the storage medium for upgrading the MCU, the method, the device, the electronic equipment and the storage medium for upgrading the MCU can avoid the problem of error of the file to be upgraded issued by the upper computer during the MCU upgrading by performing CRC on the whole received file to be upgraded.
Referring to fig. 1 of the specification, in an embodiment, the method for upgrading an MCU provided by the present application includes the following steps:
S1, responding to an upgrade instruction sent by an upper computer, modifying an upgrade flag bit of the MCU into an upgrade state, and restarting the MCU;
In order to clearly understand the technical scheme of the embodiment of the application, an application scenario can be illustrated first, and in the application, the upper computer is connected with the MCU through a wireless media module or a wired transmission module, and can directly send out a computer or other forms of terminals for controlling commands. In the application, the upper computer is used for sending an upgrade instruction and a file to be upgraded to the MCU, wherein the file to be upgraded can be a matched upgrade file aiming at the latest version of the software in the MCU and is used for updating or improving the performance of corresponding communication equipment.
In an embodiment, the upper computer may first send a version number query request to the MCU, where the MCU sends current version number information to the upper computer according to the version number query request sent by the MCU, and the upper computer compares the received current version number information of the MCU with the latest version number information, and if it is found that the current version number information of the MCU is inconsistent with the latest version number information, the upper computer sends an upgrade instruction to the MCU. In step S1, when the upper computer sends an upgrade instruction to the MCU, the upgrade flag bit in the MCU driving layer can be modified to an in-upgrade state, and the MCU can be restarted. The MCU comprises a driving layer and an application layer, wherein the driving layer is used for judging whether the MCU is upgraded or not and receiving a file to be upgraded so as to upgrade a program in the application layer, namely, the current program in the application layer is replaced by the latest version of the file to be upgraded received by the driving layer. And only when the upgrading flag bit in the driving layer is in an upgrading state, the MCU can receive the file to be upgraded transmitted by the upper computer.
Referring to fig. 2 of the specification, in the present application, before responding to an upgrade instruction sent by an upper computer, a file to be upgraded is further generated by:
S101, calculating CRC check codes of upgrade source files;
S102, placing the CRC code at the appointed position of the upgrading source file to obtain a file to be upgraded.
The upgrade source file is added with CRC check codes at designated positions to form a new upgrade bin file, wherein the new upgrade bin file is a file to be upgraded which is to be sent to an upper computer by an upper computer and is used for CRC check of a subsequent MCU after receiving the file to be upgraded so as to judge whether the upgrade source file is a correct upgrade source file.
The CRC check (Cyclic Redundancy Check ) is a data transmission error detection function, performs polynomial calculation on data, attaches the obtained result to the back of a frame, and simultaneously executes a similar algorithm on a receiving end so as to ensure the accuracy and the integrity of the data in the communication transmission process. For example, the K bits of data to be transmitted corresponds to a polynomial K (x) of degree K-1; the sender and the receiver agree with a generator polynomial G (x), and the highest power of the generator polynomial is set as r; adding r 0s at the end of the transmission data, then its corresponding polynomial M (x) =xrk (x); dividing M (x) by G (x), and dividing by modulo 2 to obtain quotient Q (x) and remainder R (x), wherein M (x) =Q (x) =G (x) +R (x), wherein remainder R (x) is CRC check code; let T (x) =m (x) +r (x), the data corresponding to T (x) is the data corresponding to the remainder added at the end of the original data block, the transmitting end transmits T (x), the receiving end receives the data T (x), divides T' (x) by G (x), if the remainder is 0, no error occurs in the transmission process, and the received data is the same as the transmitted data; otherwise, errors occur in the data transmission process.
S2, responding to the operation that the MCU reads the upgrading flag bit to be in an upgrading state, and receiving a file to be upgraded sent by the upper computer;
When the MCU is restarted and the upgrade flag bit read by the driving layer is in an upgrade state, the MCU starts to receive a file to be upgraded sent by the upper computer. In an embodiment, referring to fig. 3 of the specification, the method for receiving the file to be upgraded sent by the upper computer includes the following steps:
S201, receiving data packets of files to be upgraded sent by an upper computer one by one; wherein, the file to be upgraded at least consists of one data packet;
S202, checking each data packet of a file to be upgraded, which is sent by a received upper computer; if the verification is correct, feedback information for verifying the correctness is sent to the upper computer, so that the upper computer continues to send the next data packet; if the data packet is checked to be wrong, feedback information of the checking error is sent to the upper computer, so that the upper computer resends the data packet.
S203, storing the data of the data packet with correct verification into an external memory;
s204, storing the data of all the data packets with correct verification into an external memory to obtain a file to be upgraded, which is sent by the upper computer.
When the upper computer sends the file to be upgraded, the data of the file to be upgraded is packaged and packaged into a plurality of data packets, the data packets are used as units to be sent to the MCU one by one in sequence, and in order to ensure the accuracy and the integrity of the data in the communication transmission process, each data packet transmitted is checked in the application, and the checking mode can be parity check or accumulation and check, or can be the CRC check.
Wherein, the parity check is divided into odd check and even check by taking the odd number or even number of 1 in the transmission data (binary) as a judgment basis; examples: if the transmission data is 8b'0000_0011, two 1 s in the data are provided, the check bit is 1, the actual transmission data is 8b 0000_0011_1, and the number of 1 s in the transmission data is guaranteed to be odd. One of the most common types of accumulation and check is to add one byte of check data into the last communication data packet, wherein the byte content is the byte-wise accumulation sum of neglected carry of all data in the data packet; for example, the data to be transmitted is 1,2,3; the data added with the checksum is 1,2,3 and 6; and 6 is the checksum of the first three bytes, the receiver receives all the data and then performs the same accumulation calculation on the first three data, and if the accumulated data is the same as the last byte, the data is considered to be transmitted without errors. Which verification mode is adopted can be selected according to the actual scene, and the application limits and fixes the verification mode.
When the data packet received by the MCU is checked, if errors are found, the upper computer sends feedback information of the check errors to the upper computer, the upper computer sends the data packet again after receiving the feedback information of the check errors, and the upper computer sends feedback information of the check errors to the upper computer until the check result is correct after the MCU receives the data packet, and the upper computer continues to send the next data packet to the MCU after receiving the feedback information of the check strives for. In the application, the data of the data packet which is checked and strived is temporarily stored in the external flash memory until all data packet data which is sent by the upper computer and is checked and correct are received, and the file to be upgraded which is stored in the external flash memory is generated. The temporary storage of the file to be upgraded in the external flash memory can avoid the situation of data loss caused by transmission interruption due to power failure and the like, and the data is imported to an application layer for program replacement if the data of one data packet is received, and the MCU cannot operate if the situation of transmission interruption occurs and the program of the current version cannot be completely replaced.
S3, after the data of the file to be upgraded sent by the upper computer is completely received, calculating a check code of the received file to be upgraded, and comparing the CRC check code of the received file to be upgraded with the CRC check code of the file to be upgraded; if the received CRC check code of the file to be upgraded is consistent with the CRC check code of the file to be upgraded, modifying the upgrade flag bit of the MCU to be in an upgrade success state, and restarting the MCU;
That is, in the application, in addition to checking the data of each data packet of the file to be upgraded sent by the upper computer, the whole data of the file to be upgraded is checked again, and only if the received CRC check code of the file to be upgraded is consistent with the CRC check code of the file to be upgraded, the upper computer is indicated that the file to be upgraded is selected to be sent correctly, and then, the upgrade flag bit of the MCU is modified to be in an upgrade success state, and the MCU is restarted; if the received CRC check code of the file to be upgraded is inconsistent with the CRC check code of the file to be upgraded, the upper computer is indicated to analyze the error of the upgrade source file or select the error file to be upgraded to send, and then the upgrade flag bit of the MCU is modified to be in an upgrade failure state, and the MCU is restarted.
It should be noted that, only when the received CRC check code of the file to be upgraded is consistent with the CRC check code of the file to be upgraded, the current version program in the application layer is erased, and the file to be upgraded is written into the application layer from the external flash memory, so as to realize program upgrade; and when the received CRC check code of the file to be upgraded is inconsistent with the CRC check code of the file to be upgraded, the current version program in the application layer is not processed, namely the file to be upgraded with the verification error is not written into the application layer from the external flash memory.
And S4, responding to the MCU to read the operation that the upgrading flag bit is in an upgrading success state, and running the received file to be upgraded by the MCU.
When the MCU is restarted and the upgrade flag bit read by the drive layer is in an upgrade success state, the MCU starts to execute a file to be upgraded in the application layer, namely, a program of the latest version is operated; when the MCU is restarted and the upgrade flag bit read by the drive layer is in an upgrade failure state, the MCU still executes the program of the original version in the application layer.
According to the MCU upgrading method provided by the application, the upgrade source file is added with the CRC code at the designated position to form the file to be upgraded, and then the file to be upgraded is sent to the MCU by the upper computer, wherein in the data transmission process, the data of each data packet of the received file to be upgraded is checked, and after all the data packets are received, CRC check is carried out on the whole received file to be upgraded, so that on one hand, the correct and complete data in the transmission process is ensured, and on the other hand, the phenomenon that the MCU cannot be used after the upgrade is completed due to the fact that the upper computer analyzes the upgrade source file error or the selected file to be upgraded is avoided; and when the file to be upgraded is not completely received, the file to be upgraded is temporarily stored in an external flash memory, so that the problem that the MCU cannot operate due to transmission interruption is avoided.
Based on the same inventive concept, the embodiment of the application also provides an MCU upgrading device, and since the principle of solving the problem of the device in the embodiment of the application is similar to that of the MCU upgrading method in the embodiment of the application, the implementation of the device can be referred to the implementation of the method, and the repetition is omitted.
As shown in fig. 4 of the specification, the application also provides an MCU upgrading device, which comprises:
The modification module 401 is configured to modify an upgrade flag bit of the MCU to an upgrade state in response to an upgrade instruction sent by the upper computer, and restart the MCU;
A receiving module 402, configured to respond to an operation that the MCU reads that the upgrade flag bit is in an upgrade state, and receive a file to be upgraded sent by the upper computer;
The checking module 403 is configured to calculate a check code of the received file to be upgraded after the data of the file to be upgraded sent by the upper computer is completely received, and compare the received CRC check code of the file to be upgraded with the CRC check code of the file to be upgraded; if the received CRC check code of the file to be upgraded is consistent with the CRC check code of the file to be upgraded, modifying the upgrade flag bit of the MCU to be in an upgrade success state, and restarting the MCU;
And the operation module 404 is used for responding to the operation that the MCU reads the upgrade flag bit to be in an upgrade success state, and the MCU operates the received file to be upgraded.
In some embodiments, before the modification module 401 responds to the upgrade instruction sent by the host computer, it is further configured to calculate a CRC check code for the upgrade source file; and placing the CRC code at the appointed position of the upgrading source file to obtain a file to be upgraded.
In some embodiments, when the receiving module 402 receives the file to be upgraded sent by the host computer, the method includes:
Receiving data packets of files to be upgraded sent by an upper computer one by one; wherein, the file to be upgraded at least consists of one data packet;
Checking each data packet of the file to be upgraded sent by the upper computer; if the verification is correct, feedback information for verifying the correctness is sent to the upper computer, so that the upper computer continues to send the next data packet; if the data packet is checked to be wrong, sending feedback information of the checking error to the upper computer so that the upper computer resends the data packet;
Storing the data of the data packet which is checked to be correct into an external memory;
And storing the data of all the data packets with correct verification into an external memory to obtain a file to be upgraded sent by the upper computer.
In some embodiments, the method for checking each data packet of the file to be upgraded sent by the received upper computer includes parity check, accumulation and check or CRC check.
In some embodiments, the verification module 403 modifies the upgrade flag bit of the MCU to be in an upgrade success state, and is further configured to restore the file to be upgraded in the external memory to the MCU before restarting the MCU.
In some embodiments, the check module 403 is further configured to modify an upgrade flag bit of the MCU to an upgrade failure state if the received CRC check code of the file to be upgraded is inconsistent with the CRC check code of the file to be upgraded, and restart the MCU; and responding to the operation that the MCU reads the upgrade flag bit to be in an upgrade failure state, and running a program before upgrade by the MCU.
In some embodiments, the generating module 803 generates complete program code according to the parameters configured by each functional component in the workflow of the program to be written and the logical relationship between the functional components, including:
Detecting each functional component and an execution state corresponding to a logic relationship between the functional components in the process of generating the program codes; wherein the execution state comprises a first execution state in which the corresponding program code is successfully generated according to the functional component and a second execution state in which the corresponding program code is not successfully generated according to the functional component;
Different graphics are adopted to correspondingly display different execution states in the code generation process in the editing interface;
And reconfiguring parameters of the functional components displaying the second execution state in the editing interface, and re-detecting until the execution states of all the functional components are the first execution state, so as to obtain complete program codes.
In some embodiments, the execution states further include a third execution state according to which the functional component is generating corresponding program code.
In some embodiments, the library of functional components further comprises a private library of functional components and a shared library of functional components; the apparatus further comprises:
The storage module is used for renaming the function components after parameter configuration is carried out on each function component dragged to the editing interface, and storing the function components to the function component private library; or the function components after parameter configuration are renamed and then stored in a function component sharing library.
In some embodiments, the editing module 802, in response to a user operation on the function component library, drags a function component selected from the function component library into an editing interface, and further includes:
judging whether the workflow of the current program to be written has similar workflow of the history program written, wherein in the process of generating codes by the history program, function components with well-configured parameters are stored in a function component private library or a function component shared library;
If the historical programming code exists, the user is responded to operate the function component library, and the function component stored in the process of generating codes by calling the historical programming from the function component private library or the function component shared library is dragged to the editing interface.
According to the MCU upgrading device provided by the application, the upgrading flag bit of the MCU is modified to be in an upgrading state by the modification module in response to the upgrading instruction sent by the upper computer, and the MCU is restarted; the receiving module responds to the MCU to read the operation that the upgrading flag bit is in the state of upgrading, and receives a file to be upgraded sent by the upper computer; after the data of the file to be upgraded sent by the upper computer is completely received, calculating a check code of the received file to be upgraded, and comparing the CRC check code of the received file to be upgraded with the CRC check code of the file to be upgraded; if the received CRC check code of the file to be upgraded is consistent with the CRC check code of the file to be upgraded, modifying the upgrade flag bit of the MCU to be in an upgrade success state, and restarting the MCU; and responding the MCU to read the operation of the upgrade flag bit in an upgrade success state through an operation module, and operating the received file to be upgraded by the MCU. The CRC is carried out on the whole received file to be upgraded, so that the phenomenon that the MCU cannot be used after upgrading is finished due to the fact that the file to be upgraded is wrongly issued by an upper computer during MCU upgrading can be avoided.
Based on the same concept of the present application, fig. 5 of the present disclosure shows a structure of an electronic device 500 according to an embodiment of the present application, where the electronic device 500 includes: at least one processor 501, at least one network interface 504 or other user interface 503, memory 505, at least one communication bus 502. The communication bus 502 is used to enable connected communications between these components. The electronic device 500 optionally includes a user interface 503 including a display (e.g., a touch screen, LCD, CRT, holographic imaging (Holographic) or projection (Projector), etc.), a keyboard, or a pointing device (e.g., a mouse, trackball, touch pad, touch screen, etc.).
Memory 505 may include read only memory and random access memory and provides instructions and data to processor 501. A portion of the memory 505 may also include non-volatile random access memory (NVRAM).
In some implementations, the memory 505 stores the following elements, executable modules or data structures, or a subset thereof, or an extended set thereof:
An operating system 5051 containing various system programs for implementing various basic services and handling hardware-based tasks;
application module 5052 contains various application programs such as desktop (desktop), media player (MEDIA PLAYER), browser (Browser), etc. for implementing various application services.
In the embodiment of the present application, the processor 501 is configured to execute steps in an MCU upgrade method by calling a program or an instruction stored in the memory 505, and perform CRC check on the whole received file to be upgraded, so as to avoid the problem of error in the file to be upgraded issued by the upper computer during MCU upgrade.
The application also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs steps as in an MCU upgrade method.
In particular, the storage medium can be a general-purpose storage medium, such as a removable disk, a hard disk, etc., and the computer program on the storage medium can execute the MCU upgrade method described above when executed.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments provided in the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method of the embodiments of the present application. And the aforementioned storage medium includes: a usb disk, a removable hard disk, a read-only memory (ROM), a random access memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Finally, it should be noted that: the above examples are only specific embodiments of the present application for illustrating the technical aspects of the present application, but not for limiting the scope of the present application, and although the present application has been described in detail with reference to the above examples, it is to be understood that the present application is not limited thereto.

Claims (10)

1. An MCU upgrading method is characterized by comprising the following steps:
responding to an upgrade instruction sent by the upper computer, modifying an upgrade flag bit of the MCU into an upgrade state, and restarting the MCU;
Responding to the operation that the MCU reads the upgrading flag bit to be in an upgrading state, and receiving a file to be upgraded sent by an upper computer;
After the data of the file to be upgraded sent by the upper computer is completely received, calculating a check code of the received file to be upgraded, and comparing the CRC check code of the received file to be upgraded with the CRC check code of the file to be upgraded; if the received CRC check code of the file to be upgraded is consistent with the CRC check code of the file to be upgraded, modifying the upgrade flag bit of the MCU to be in an upgrade success state, and restarting the MCU;
And responding to the operation that the MCU reads the upgrade flag bit to be in an upgrade success state, and running the received file to be upgraded by the MCU.
2. The method for upgrading an MCU according to claim 1, wherein before said responding to the upgrade instruction sent by the host computer, further comprising the steps of:
calculating CRC check codes of the upgrade source files;
and placing the CRC code at the appointed position of the upgrading source file to obtain a file to be upgraded.
3. The method for upgrading an MCU according to claim 2, wherein the step of receiving the data of the file to be upgraded transmitted by the upper computer comprises the following steps:
Receiving data packets of files to be upgraded sent by an upper computer one by one; wherein, the file to be upgraded at least consists of one data packet;
Checking each data packet of the file to be upgraded sent by the upper computer; if the verification is correct, feedback information for verifying the correctness is sent to the upper computer, so that the upper computer continues to send the next data packet; if the data packet is checked to be wrong, feedback information of the checking error is sent to the upper computer, so that the upper computer resends the data packet.
4. A method for upgrading an MCU according to claim 3, wherein the checking of each data packet of the file to be upgraded sent by the host computer further comprises the steps of:
Storing the data of the data packet which is checked to be correct into an external memory;
And storing the data of all the data packets with correct verification into an external memory to obtain a file to be upgraded sent by the upper computer.
5. The method for upgrading an MCU according to claim 4, wherein the method for checking each data packet of the file to be upgraded sent by the upper computer comprises parity check, accumulation and check or CRC check.
6. The method for upgrading an MCU according to claim 5, wherein the modifying the upgrade flag bit of the MCU to an upgrade success state, before restarting the MCU, further comprises the steps of:
and transferring the file to be upgraded in the external memory to the MCU.
7. The method for upgrading an MCU according to claim 6, wherein the comparing the received CRC check code of the file to be upgraded with the CRC check code of the file to be upgraded further comprises the steps of:
If the received CRC check code of the file to be upgraded is inconsistent with the CRC check code of the file to be upgraded, modifying the upgrade flag bit of the MCU into an upgrade failure state, and restarting the MCU;
And responding to the operation that the MCU reads the upgrade flag bit to be in an upgrade failure state, and running a program before upgrade by the MCU.
8. An MCU upgrade apparatus, said apparatus comprising:
The modification module is used for responding to an upgrade instruction sent by the upper computer, modifying an upgrade flag bit of the MCU into an upgrade state and restarting the MCU;
the receiving module is used for responding to the operation that the MCU reads the upgrading flag bit to be in an upgrading state and receiving a file to be upgraded sent by the upper computer;
The checking module is used for calculating a check code of the received file to be upgraded after the data of the file to be upgraded sent by the upper computer is completely received, and comparing the CRC check code of the received file to be upgraded with the CRC check code of the file to be upgraded; if the received CRC check code of the file to be upgraded is consistent with the CRC check code of the file to be upgraded, modifying the upgrade flag bit of the MCU to be in an upgrade success state, and restarting the MCU;
And the running module is used for responding to the operation that the MCU reads the upgrading flag bit to be in an upgrading success state, and the MCU runs the received file to be upgraded.
9. An electronic device, comprising: a processor, a memory and a bus, said memory storing machine readable instructions executable by said processor, said processor and said memory communicating over the bus when the electronic device is running, said machine readable instructions when executed by said processor performing the steps of the MCU upgrade method of any of claims 1 to 7.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, performs the steps of the MCU upgrade method of any one of claims 1 to 7.
CN202211236874.8A 2022-10-10 2022-10-10 MCU upgrading method and device, electronic equipment and storage medium Pending CN117908910A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211236874.8A CN117908910A (en) 2022-10-10 2022-10-10 MCU upgrading method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211236874.8A CN117908910A (en) 2022-10-10 2022-10-10 MCU upgrading method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117908910A true CN117908910A (en) 2024-04-19

Family

ID=90682482

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211236874.8A Pending CN117908910A (en) 2022-10-10 2022-10-10 MCU upgrading method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117908910A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118151977A (en) * 2024-05-13 2024-06-07 深圳市易优电气有限公司 Firmware upgrading method and system of controller chip

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118151977A (en) * 2024-05-13 2024-06-07 深圳市易优电气有限公司 Firmware upgrading method and system of controller chip

Similar Documents

Publication Publication Date Title
CN106843942B (en) Wearable device and firmware upgrading method thereof
US9513900B2 (en) Peripheral device and method for updating firmware thereof
CN106325929B (en) Firmware upgrading method, firmware upgrading device, refrigerator and server
CN107908417B (en) Firmware upgrading method and electronic equipment
CN104007996A (en) Reliable firmware upgrading realizing method for distributed control system
CN108121543B (en) Software code compiling processing method and device
CN114281394A (en) Method, system, equipment and medium for fast on-line upgrading program
CN111813428A (en) Method and device for upgrading terminal firmware, electronic equipment and storage medium
CN117908910A (en) MCU upgrading method and device, electronic equipment and storage medium
CN112015447B (en) System updating method and device of electronic equipment, electronic equipment and storage medium
CN113760332A (en) Software upgrading method and electronic equipment
CN112650518A (en) DSP program on-line upgrading method
CN102880478B (en) Oftware updating method
CN113672270A (en) Upgrading method, computer system and remote upgrading device
CN106293621B (en) A kind of firmware upgrade method and device
CN116700765A (en) Firmware upgrading method and device of servo driver and servo driver
CN111142919B (en) Method suitable for simultaneous upgrading of multiple groups of MCU unit programs
CN111104138A (en) Firmware upgrading method and device and computer readable storage medium
CN112540799A (en) Management method, system, terminal device and storage medium of startup data
WO2021005691A1 (en) Control device, program monitoring method, and program
CN107480007B (en) Program redundancy check and error correction method
CN109254936B (en) Method and device for inserting data transmission queue structure
CN112657196A (en) Resource updating method and device, computer equipment and readable storage medium
CN112015428A (en) Compiling environment creating method and device and host
CN115878145B (en) Electronic device, system upgrading method thereof and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination