Method and device for realizing firmware upgrading, equipment and storage medium

By receiving and verifying upgrade files and using a common protocol to enable communication between the MCU and the target hardware, the problem of inconvenient upgrades of peripheral hardware of the MCU is solved, and the ease of operation and efficiency are improved.

CN120929104APending Publication Date: 2025-11-11DONGFENG ELECTRONICS TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511070335.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-31
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

In existing technologies, upgrading the peripheral hardware of MCUs is inconvenient and inefficient, and the lack of exposed communication interfaces leads to inconvenient operation and low efficiency.

Method used

By receiving the upgrade file sent by the host computer, the MCU sends initialization and erase commands to the target hardware, uses a general protocol to establish a communication connection between the MCU and the target hardware, splits and verifies the upgrade file, and ensures that it is successfully written to the backup area and copied to the running area.

Benefits of technology

It enables convenient upgrades to MCU peripheral hardware, improves operational efficiency, and ensures the reliability and efficiency of the upgrade process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120929104A_ABST
    Figure CN120929104A_ABST
Patent Text Reader

Abstract

The invention discloses a method, a device and equipment for realizing firmware upgrading and a computer readable storage medium. The method is applied to a microcontroller MCU, an upgrading file of firmware to be upgraded sent by an upper computer based on a general protocol is received, target hardware is determined according to the upgrading file, and the firmware to be upgraded runs on the target hardware; when the target hardware is in communication connection with the MCU, an initialization instruction is sent to the target hardware, so that the target hardware enters an upgrading preparation state; when the target hardware enters the upgrading preparation state, an erasing instruction is sent to the target hardware, so that the target hardware erases data of the firmware to be upgraded in the backup area; and after the target hardware successfully erases the data of the firmware to be upgraded in the backup area, sending an upgrading file to the target hardware, so that the target hardware writes the upgrading file into the backup area. By means of the method, the MCU directly completes upgrading for peripheral hardware of the MCU, the operation convenience is improved, and the operation efficiency is also improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of firmware upgrades, and specifically to a method, apparatus, device, and computer-readable storage medium for implementing firmware upgrades. Background Technology

[0002] Firmware upgrade programs are special programs embedded in the Flash or ROM of a microcontroller (MCU) in an embedded system. Their main function is to load the operating system or application, jump to new programs, and upgrade the MCU program after the device is powered on or reset.

[0003] In existing firmware upgrade technologies, the MCU typically acts as a slave device, passively receiving instructions and data from the master and using the firmware upgrade program to upgrade itself. This limitation is particularly noticeable in systems with a large amount of hardware. When hardware in the MCU's peripheral circuitry needs upgrading, these devices often lack exposed communication interfaces. The upgrade often requires either returning the device to the factory for reprogramming or removing it from the system and bringing out its communication interface, both of which are inconvenient and inefficient. Summary of the Invention

[0004] This application provides a method, apparatus, device, and computer-readable storage medium for firmware upgrades, which can solve the technical problems of inconvenient and inefficient upgrades of MCU peripheral hardware in the prior art.

[0005] In a first aspect, embodiments of this application provide a method for implementing firmware upgrades, wherein the method for implementing firmware upgrades is applied to a microcontroller (MCU), and the method for implementing firmware upgrades includes: The system receives an upgrade file for the firmware to be upgraded from a host computer based on a common protocol, and determines the target hardware based on the upgrade file, wherein the firmware to be upgraded runs on the target hardware. When the target hardware has a communication connection with the MCU, an initialization command is sent to the target hardware so that the target hardware can enter the upgrade preparation state; Once the target hardware enters the upgrade preparation state, an erase command is sent to the target hardware so that the target hardware can erase the data of the firmware to be upgraded in the backup area; Once the target hardware successfully erases the data of the firmware to be upgraded from the backup area, the upgrade file is sent to the target hardware so that the target hardware can write the upgrade file into the backup area.

[0006] In conjunction with the first aspect, in one implementation, sending an erase command to the target hardware to erase the data of the firmware to be upgraded in the backup area specifically includes: Based on the size of the upgrade file, determine whether the backup area storing the firmware to be upgraded can accommodate the upgrade file; If possible, an erase command is sent to the target hardware. The erase command includes the size of the area to be erased, so that the target hardware can erase the data of the firmware to be upgraded in the backup area based on the size of the area to be erased. Receive the erase operation execution result returned by the target hardware; If the erase operation fails, the step of sending the erase command to the target hardware is executed until the erase operation is successful or the preset number of retries is reached.

[0007] In conjunction with the first aspect, in one embodiment, after determining whether the backup area storing the firmware to be upgraded can accommodate the upgrade file based on the upgrade file size, the method further includes: If the space cannot be filled, an erase command is sent to the memory chip so that the memory chip can erase the data in the preset storage area. After the memory chip successfully erases the data in the preset storage area, it splits the upgrade file into multiple data blocks and sends them to the memory chip so that the memory chip can write the upgrade file into the preset storage area. Each data block includes m data frames. The memory chip has a communication connection with the MCU. Verify each data frame in each data block received in the preset storage area of ​​the memory chip, and output the verification result; If a verification failure occurs, the data frame corresponding to the verification failure is resent to the storage chip until no verification failure occurs.

[0008] In conjunction with the first aspect, in one embodiment, the method further includes: The upgrade file received in the preset storage area of ​​the memory chip is split into multiple data blocks and copied to the running area of ​​the target hardware. Each data block includes m data frames. Verify each data frame in each data block received in the target hardware's runtime area and output the verification result; If the verification result is that the copying failed, the step of splitting the upgrade file received in the preset storage area of ​​the storage chip into multiple data blocks and copying them to the running area of ​​the target hardware is executed. If the verification result indicates successful copying, a restart command is sent to the target hardware so that the target hardware can restart and run the upgrade file.

[0009] In conjunction with the first aspect, in one implementation, sending the upgrade file to the target hardware includes: The upgrade file is split into multiple data blocks and sent to the target hardware, where each data block includes m data frames; Each data frame in each data block received from the target hardware is verified, and the verification result is output, which is either a verification pass result or a verification failure result. If a verification failure occurs, the data frame corresponding to the verification failure is resent to the target hardware until no verification failure occurs.

[0010] In conjunction with the first aspect, in one implementation, after verifying each data frame in each data block received from the target hardware and outputting the verification result, the method further includes: If the number of failed verification results is greater than or equal to the preset value, an error log is recorded and the upgrade process is terminated.

[0011] In conjunction with the first aspect, in one implementation, after the target hardware successfully erases the data of the firmware to be upgraded in the backup area, the upgrade file is sent to the target hardware so that the target hardware can write the upgrade file into the backup area, and the implementation further includes: Once the target hardware successfully writes the upgrade file to the backup area, the upgrade file in the target hardware backup area is copied to the runtime area. Verify each data frame in each data block received in the target hardware's runtime area and output the verification result; If the verification result indicates that the copying failed, proceed with the step of copying the upgrade file from the target hardware backup area to the runtime area. If the verification result indicates successful copying, a restart command is sent to the target hardware so that the target hardware can restart and run the upgrade file.

[0012] Secondly, embodiments of this application provide an apparatus for implementing firmware upgrades, the apparatus comprising: Receiving module: Receives the upgrade file of the firmware to be upgraded sent by the host computer based on a general protocol, and determines the target hardware according to the upgrade file, wherein the firmware to be upgraded runs on the target hardware.

[0013] Sending module: When the target hardware has a communication connection with the MCU, it sends an initialization command to the target hardware to enable the target hardware to enter the upgrade preparation state; after the target hardware enters the upgrade preparation state, it sends an erase command to the target hardware to enable the target hardware to erase the data of the firmware to be upgraded in the backup area; after the target hardware successfully erases the data of the firmware to be upgraded in the backup area, it sends the upgrade file to the target hardware so that the target hardware can write the upgrade file into the backup area.

[0014] Thirdly, embodiments of this application provide an apparatus for implementing firmware upgrades. The apparatus for implementing firmware upgrades includes a processor, a memory, and a program for implementing firmware upgrades stored in the memory and executable by the processor. When the program for implementing firmware upgrades is executed by the processor, it implements the steps of the method for implementing firmware upgrades as described in any one of the first aspects.

[0015] Fourthly, embodiments of this application provide a computer-readable storage medium, wherein when the program for implementing firmware upgrades is executed by a processor, it implements the steps of the method for implementing firmware upgrades as described above.

[0016] The beneficial effects of the technical solutions provided in this application include: By receiving the upgrade file of the firmware to be upgraded from the host computer based on a common protocol, the target hardware is determined according to the upgrade file, wherein the firmware to be upgraded runs on the target hardware. When the target hardware has a communication connection with the MCU, an initialization command is sent to the target hardware to put it into an upgrade preparation state. After the target hardware enters the upgrade preparation state, an erase command is sent to the target hardware to erase the data of the firmware to be upgraded in the backup area. After the target hardware successfully erases the data of the firmware to be upgraded in the backup area, the upgrade file is sent to the target hardware so that the target hardware can write the upgrade file into the backup area. This allows the target hardware to copy the upgrade file to the running area. Through this method, the MCU can directly upgrade its peripheral hardware, improving the convenience and efficiency of operation. Attached Figure Description

[0017] Figure 1 This is a flowchart illustrating an embodiment of the firmware upgrade method of this application; Figure 2 A schematic diagram of functional modules of an embodiment of the apparatus for implementing firmware upgrades according to this application; Figure 3 This is a schematic diagram of the hardware structure of the device for implementing firmware upgrades involved in the embodiments of this application. Detailed Implementation

[0018] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.

[0019] First, some of the technical terms used in this application will be explained to help those skilled in the art understand this application.

[0020] Firmware: refers to the software embedded in electronic devices, which is responsible for controlling the basic functions and operating logic of the hardware.

[0021] General Protocol: A standardized communication specification that defines the format, timing, and interaction logic of data transmission, shields hardware differences, and enables seamless communication between the MCU, the host computer, and peripheral hardware.

[0022] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0023] In a first aspect, embodiments of this application provide a method for implementing firmware upgrades.

[0024] In one embodiment, reference is made to Figure 1 , Figure 1 This is a flowchart illustrating an embodiment of the firmware upgrade method of this application. Figure 1 As shown, the methods for implementing firmware upgrades include: Step S10: Receive the upgrade file of the firmware to be upgraded sent by the host computer based on a general protocol, and determine the target hardware according to the upgrade file, wherein the firmware to be upgraded runs on the target hardware; In one embodiment, the host computer of the microcontroller MCU is the host. Assuming that firmware A in the TP chip needs to be upgraded, the TP chip is the target hardware. The host sends the firmware A upgrade file to the MCU. The upgrade file carries the identifier of the TP chip. The MCU can identify the TP chip based on the identifier in the upgrade file.

[0025] Step S20: When the target hardware has a communication connection with the MCU, an initialization command is sent to the target hardware so that the target hardware can enter the upgrade preparation state. In one embodiment, the MCU can upgrade peripheral hardware with which it has a communication connection. The MCU is the host in the form of the target hardware. Taking the target hardware as a TP chip as an example, the MCU sends an initialization command to the TP chip. After receiving the initialization command, the TP chip begins to perform a series of preparatory upgrade operations, such as resetting the TP chip, entering an idle waiting command state, clearing all current error flag information, entering data encryption mode, obtaining write permissions for the TP backup area and removing write protection, etc. The role of the MCU in this process is to control the TP state according to the usage requirements so that it meets the requirements of the next erasure step.

[0026] Step S30: After the target hardware enters the upgrade preparation state, an erase command is sent to the target hardware so that the target hardware can erase the data of the firmware to be upgraded in the backup area. Furthermore, the step of sending an erase command to the target hardware so that the target hardware can erase the data of the firmware to be upgraded in the backup area specifically includes: Based on the size of the upgrade file, determine whether the backup area storing the firmware to be upgraded can accommodate the upgrade file, wherein the backup area storing the firmware to be upgraded is the area to be erased. If possible, an erase command is sent to the target hardware. The erase command includes the size of the area to be erased, so that the target hardware can erase the data of the firmware to be upgraded in the backup area based on the size of the area to be erased. Receive the erase operation execution result returned by the target hardware; If the erase operation fails, the step of sending the erase command to the target hardware is executed until the erase operation is successful or the preset number of retries is reached. In one embodiment, after the TP chip enters the upgrade preparation state, the MCU needs to determine whether the backup area storing the firmware to be upgraded in the TP can accommodate the firmware to be upgraded, based on the size of the upgrade file. If it can, the MCU sends an erase command to the TP chip and sends the size of the area to be erased to the TP chip. The TP chip erases the data of the firmware to be upgraded stored in the area to be erased and feeds back the execution result of the erase operation to the MCU. If the erase fails, the MCU resends the erase command to the TP chip until the erase is successful, or if it still fails after multiple attempts, the subsequent process is terminated.

[0027] Furthermore, after determining whether the backup area storing the firmware to be upgraded can accommodate the upgrade file based on the upgrade file size, the method further includes: If the space cannot be filled, an erase command is sent to the memory chip so that the memory chip can erase the data in the preset storage area. After the memory chip successfully erases the data in the preset storage area, it splits the upgrade file into multiple data blocks and sends them to the memory chip so that the memory chip can write the upgrade file into the preset storage area. Each data block includes m data frames. The memory chip has a communication connection with the MCU. Verify each data frame in each data block received in the preset storage area of ​​the memory chip, and output the verification result; If a verification failure occurs, the data frame corresponding to the verification failure is resent to the storage chip until no verification failure occurs.

[0028] In one embodiment, if the backup area storing the firmware to be upgraded in the target hardware cannot accommodate the upgrade file, the upgrade file is split into multiple data blocks and sent to an external storage chip. The storage chip must have a communication connection with the MCU. Assuming the upgrade file is divided into 5 data blocks, each data block contains 8 data frames, and the size of each data frame is related to the transmission capacity of the target hardware, the storage chip writes the upgrade file packet by packet into its preset storage area. This preset storage area is used to temporarily store the upgrade file. After the storage chip writes the upgrade file packet by packet into its preset storage area, the MCU reads back and verifies each frame in each data block to determine if there are any verification failures. If the first data frame of a second data packet fails verification, the frame is resent to the storage chip until there are no verification failures in the entire upgrade file.

[0029] Furthermore, the method also includes: The upgrade file received in the preset storage area of ​​the memory chip is split into multiple data blocks and copied to the running area of ​​the target hardware. Each data block includes m data frames. Verify each data frame in each data block received in the target hardware's runtime area and output the verification result; If the verification result is that the copying failed, the step of splitting the upgrade file received in the preset storage area of ​​the storage chip into multiple data blocks and copying them to the running area of ​​the target hardware is executed. If the verification result indicates successful copying, a restart command is sent to the target hardware so that the target hardware can restart and run the upgrade file.

[0030] In one embodiment, after the upgrade file is successfully written to the preset storage area of ​​the memory chip, similarly to the erasure method of the backup area, the MCU sends an erasure command to the target hardware and sends the size of the area to be erased in the running area to the target hardware. The target hardware erases the data of the firmware to be upgraded in the area to be erased in the running area and feeds back the execution result of the erasure operation to the MCU. If the erasure fails, the MCU resends the erasure command to the target hardware until the erasure is successful. After the erasure is successful, the upgrade file written in the preset storage area of ​​the memory chip is split into multiple data blocks and copied to the running area of ​​the target hardware. Then, the upgrade file in the running area of ​​the target hardware is read back and verified packet by packet. If the verification result fails, the MCU re-executes the copying action. If the copying result is successful, the MCU controls the target hardware to restart and run the upgrade file, thereby realizing the upgrade of the target hardware.

[0031] In this embodiment, when the backup area of ​​the target hardware cannot accommodate the upgrade file, the upgrade file is first written to an external storage chip. After verification, it is then written to the target hardware. This process of determining whether the backup area of ​​the target hardware can accommodate the upgrade file achieves the effect of internal control of the upgrade process within the MCU, avoiding the situation where the original running files in the target hardware are erased and there are no new files available, thus ensuring the reliability of the upgrade process.

[0032] Step S40: After the target hardware successfully erases the data of the firmware to be upgraded in the backup area, the upgrade file is sent to the target hardware so that the target hardware can write the upgrade file into the backup area.

[0033] Furthermore, sending the upgrade file to the target hardware includes: The upgrade file is split into multiple data blocks and sent to the target hardware, where each data block includes m data frames; Each data frame in each data block received from the target hardware is verified, and the verification result is output, which is either a verification pass result or a verification failure result. If a verification failure occurs, the data frame corresponding to the verification failure is resent to the target hardware until no verification failure occurs.

[0034] Furthermore, after verifying each data frame in each data block received from the target hardware and outputting the verification result, the method further includes: If the number of failed verification results is greater than or equal to the preset value, an error log is recorded and the upgrade process is terminated.

[0035] In one embodiment, assuming the TP chip is the target hardware, after the TP chip successfully erases the data of the firmware to be upgraded, the MCU splits the upgrade file into multiple data blocks, assuming each data block contains 8 data frames, and sends them to the backup area of ​​the target hardware. Then, the MCU verifies the upgrade file received in the target hardware packet by packet and frame by frame. If the verification of the second data frame of the third data packet fails, the MCU resends the failed data frame to the TP chip and re-verifies it until the verification is successful. If all verifications are successful, the upgrade file is considered to have been successfully written to the target hardware. If the MCU receives a verification result showing that the number of failures exceeds 8, an error log is recorded and the upgrade process is terminated.

[0036] Furthermore, after the target hardware successfully erases the data of the firmware to be upgraded in the backup area, the upgrade file is sent to the target hardware so that the target hardware can write the upgrade file into the backup area. The process also includes: Once the target hardware successfully writes the upgrade file to the backup area, the upgrade file in the target hardware backup area is copied to the runtime area. Verify each data frame in each data block received in the target hardware's runtime area and output the verification result; If the verification result indicates that the copying failed, proceed with the step of copying the upgrade file from the target hardware backup area to the runtime area. If the verification result indicates successful copying, a restart command is sent to the target hardware so that the target hardware can restart and run the upgrade file.

[0037] In one embodiment, the TP chip is still used as the target hardware. After the TP chip successfully writes the upgrade file to the backup area, the MCU verifies the upgrade file received in the TP chip's backup area. If the verification is successful, the MCU sends an erase command to the TP chip and sends the size of the area to be erased in the TP chip's running area to the TP chip. The TP chip erases the data of the firmware to be upgraded stored in the area to be erased in the running area and feeds back the execution result of the erase operation to the MCU. If the erase fails, the MCU resends the erase command to the TP chip until the erase is successful. After the erase is successful, the MCU copies the upgrade file from the TP chip's backup area to the running area. After copying, the MCU verifies the upgrade file in the running area. If the verification result is unsuccessful, the upgrade file is copied again to the TP chip's running area. If the verification result is successful, a restart command is sent to the TP chip to restart and run the upgrade file to complete the upgrade.

[0038] In this embodiment, the upgrade file of the firmware to be upgraded, sent by the host computer based on a general protocol, is received. The target hardware is determined according to the upgrade file, wherein the firmware to be upgraded runs on the target hardware. When the target hardware has a communication connection with the MCU, an initialization command is sent to the target hardware to allow it to enter the upgrade preparation state. After the target hardware enters the upgrade preparation state, an erase command is sent to the target hardware to erase the data of the firmware to be upgraded in the backup area. After the target hardware successfully erases the data of the firmware to be upgraded in the backup area, the upgrade file is sent to the target hardware so that the target hardware can write the upgrade file into the backup area. Finally, the upgrade file is copied to the running area to complete the upgrade process. Through this method, the MCU, as the host in the form of peripheral hardware, directly upgrades the peripheral hardware, resulting in higher operational efficiency.

[0039] Secondly, embodiments of this application also provide an apparatus for implementing firmware upgrades.

[0040] In one embodiment, reference is made to Figure 2 , Figure 2 This is a functional module diagram of an embodiment of the apparatus for firmware upgrade according to this application. Figure 2 As shown, the device for implementing firmware upgrades includes: The receiving module 10 is used to receive the upgrade file of the firmware to be upgraded sent by the host computer based on a general protocol, and determine the target hardware according to the upgrade file, wherein the firmware to be upgraded runs on the target hardware; The sending module 20 is used to send an initialization command to the target hardware when there is a communication connection between the target hardware and the MCU, so that the target hardware can enter the upgrade preparation state; after the target hardware enters the upgrade preparation state, it sends an erase command to the target hardware so that the target hardware can erase the data of the firmware to be upgraded in the backup area; after the target hardware successfully erases the data of the firmware to be upgraded in the backup area, it sends the upgrade file to the target hardware so that the target hardware can write the upgrade file into the backup area.

[0041] Furthermore, in one embodiment, the apparatus for implementing firmware upgrades further includes an erasure module, used for: Based on the size of the upgrade file, determine whether the backup area storing the firmware to be upgraded can accommodate the upgrade file, wherein the backup area storing the firmware to be upgraded is the area to be erased. If possible, an erase command is sent to the target hardware. The erase command includes the size of the area to be erased, so that the target hardware can erase the data of the firmware to be upgraded in the backup area based on the size of the area to be erased. Receive the erase operation execution result returned by the target hardware; If the erase operation fails, the step of sending the erase command to the target hardware is executed until the erase operation is successful or the preset number of retries is reached.

[0042] Furthermore, in one embodiment, the sending module 20 is used to: After determining whether the backup area storing the firmware to be upgraded can accommodate the upgrade file based on the upgrade file size, the method further includes: If the space cannot be filled, an erase command is sent to the memory chip so that the memory chip can erase the data in the preset storage area. After the memory chip successfully erases the data in the preset storage area, it splits the upgrade file into multiple data blocks and sends them to the memory chip so that the memory chip can write the upgrade file into the preset storage area. Each data block includes m data frames. The memory chip has a communication connection with the MCU. Verify each data frame in each data block received in the preset storage area of ​​the memory chip, and output the verification result; If a verification failure occurs, the data frame corresponding to the verification failure is resent to the storage chip until no verification failure occurs.

[0043] Furthermore, in one embodiment, the sending module 20 is used to: The upgrade file received in the preset storage area of ​​the memory chip is split into multiple data blocks and copied to the running area of ​​the target hardware. Each data block includes m data frames. Verify each data frame in each data block received in the target hardware's runtime area and output the verification result; If the verification result is that the copying failed, the step of splitting the upgrade file received in the preset storage area of ​​the storage chip into multiple data blocks and copying them to the running area of ​​the target hardware is executed. If the verification result indicates successful copying, a restart command is sent to the target hardware so that the target hardware can restart and run the upgrade file.

[0044] Furthermore, in one embodiment, the sending module 20 is used to: The upgrade file is split into multiple data blocks and sent to the target hardware, where each data block includes m data frames; Each data frame in each data block received from the target hardware is verified, and the verification result is output, which is either a verification pass result or a verification failure result. If a verification failure occurs, the data frame corresponding to the verification failure is resent to the target hardware until no verification failure occurs.

[0045] Furthermore, in one embodiment, after verifying each data frame in each data block received from the target hardware and outputting the verification result, the method further includes: If the number of failed verification results is greater than or equal to the preset value, an error log is recorded and the upgrade process is terminated.

[0046] Furthermore, in one embodiment, the sending module 20 is used to: Once the target hardware successfully writes the upgrade file to the backup area, the upgrade file in the target hardware backup area is copied to the runtime area. Verify each data frame in each data block received in the target hardware's runtime area and output the verification result; If the verification result indicates that the copying failed, proceed with the step of copying the upgrade file from the target hardware backup area to the runtime area. If the verification result indicates that the copying failed, proceed with the step of copying the upgrade file from the target hardware backup area to the runtime area. If the verification result indicates successful copying, a restart command is sent to the target hardware so that the target hardware can restart and run the upgrade file.

[0047] The functions of each module in the above-mentioned device for firmware upgrade correspond to the steps in the above-mentioned method embodiment for firmware upgrade, and their functions and implementation processes will not be described in detail here.

[0048] Thirdly, embodiments of this application provide a device for implementing firmware upgrades. The device for implementing firmware upgrades can be a personal computer (PC), a laptop computer, a server, or other device with data processing capabilities.

[0049] Reference Figure 3 , Figure 3 This is a schematic diagram of the hardware structure of a device for implementing firmware upgrades according to an embodiment of this application. In this embodiment, the device for implementing firmware upgrades may include a processor, a memory, a communication interface, and a communication bus.

[0050] The communication bus can be of any type and is used to interconnect the processor, memory, and communication interface.

[0051] Communication interfaces include input / output (I / O) interfaces, physical interfaces, and logical interfaces used for internal firmware interconnection within the device to enable firmware upgrades, as well as interfaces used for interconnection between the device enabling firmware upgrades and other devices (such as other computing devices or user equipment). Physical interfaces can be Ethernet interfaces, fiber optic interfaces, ATM interfaces, etc.; user equipment can be displays, keyboards, etc.

[0052] Memory can be various types of storage media, such as random access memory (RAM), read-only memory (ROM), non-volatile RAM (NVRAM), flash memory, optical storage, hard disk, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), etc.

[0053] The processor can be a general-purpose processor, which can call a firmware upgrade program stored in memory and execute the firmware upgrade method provided in the embodiments of this application. For example, the general-purpose processor can be a central processing unit (CPU). The method executed when the firmware upgrade program is called can be referred to in the various embodiments of the firmware upgrade method of this application, and will not be repeated here.

[0054] Those skilled in the art will understand that Figure 3The hardware structure shown does not constitute a limitation of this application and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0055] Fourthly, embodiments of this application also provide a computer-readable storage medium.

[0056] The present application provides a computer-readable storage medium storing a program for implementing firmware upgrades, wherein when the program for implementing firmware upgrades is executed by a processor, it implements the steps of the method for implementing firmware upgrades as described above.

[0057] The method implemented when the firmware upgrade program is executed can be referred to in various embodiments of the firmware upgrade method of this application, and will not be repeated here.

[0058] It should be noted that the sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0059] The terms "comprising" and "having," and any variations thereof, in the specification, claims, and accompanying drawings of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus. The terms "first," "second," and "third," etc., are used to distinguish different objects, etc., and do not indicate a sequence, nor do they limit "first," "second," and "third" to different types.

[0060] In the description of the embodiments of this application, terms such as "exemplary," "for example," or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplary," "for example," or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary," "for example," or "for instance" is intended to present the relevant concepts in a concrete manner.

[0061] In the description of the embodiments of this application, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. The "and / or" in the text is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of this application, "multiple" means two or more.

[0062] In some processes described in the embodiments of this application, multiple operations or steps are included in a specific order. However, it should be understood that these operations or steps may not be executed in the order they appear in the embodiments of this application, or they may be executed in parallel. The sequence number of the operation is only used to distinguish different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed sequentially or in parallel, and these operations or steps may be combined.

[0063] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device to execute the methods described in the various embodiments of this application.

[0064] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.

Claims

1. A method for implementing firmware upgrades, characterized in that, The method for implementing firmware upgrades is applied to a microcontroller (MCU), and the method for implementing firmware upgrades includes: The system receives an upgrade file for the firmware to be upgraded from a host computer based on a common protocol, and determines the target hardware based on the upgrade file, wherein the firmware to be upgraded runs on the target hardware. When the target hardware has a communication connection with the MCU, an initialization command is sent to the target hardware so that the target hardware can enter the upgrade preparation state; Once the target hardware enters the upgrade preparation state, an erase command is sent to the target hardware so that the target hardware can erase the data of the firmware to be upgraded in the backup area; Once the target hardware successfully erases the data of the firmware to be upgraded from the backup area, the upgrade file is sent to the target hardware so that the target hardware can write the upgrade file into the backup area.

2. The method for firmware upgrade as described in claim 1, characterized in that, The step of sending an erase command to the target hardware so that the target hardware can erase the data of the firmware to be upgraded in the backup area specifically includes: Based on the size of the upgrade file, determine whether the backup area storing the firmware to be upgraded can accommodate the upgrade file, wherein the backup area storing the firmware to be upgraded is the area to be erased. If possible, an erase command is sent to the target hardware. The erase command includes the size of the area to be erased, so that the target hardware can erase the data of the firmware to be upgraded in the backup area based on the size of the area to be erased. Receive the erase operation execution result returned by the target hardware; If the erase operation fails, the step of sending the erase command to the target hardware is executed until the erase operation is successful or the preset number of retries is reached.

3. The method for firmware upgrade as described in claim 2, characterized in that, After determining whether the backup area storing the firmware to be upgraded can accommodate the upgrade file based on the upgrade file size, the method further includes: If the space cannot be filled, an erase command is sent to the memory chip so that the memory chip can erase the data in the preset storage area. After the memory chip successfully erases the data in the preset storage area, it splits the upgrade file into multiple data blocks and sends them to the memory chip so that the memory chip can write the upgrade file into the preset storage area. Each data block includes m data frames. The memory chip has a communication connection with the MCU. Verify each data frame in each data block received in the preset storage area of ​​the memory chip, and output the verification result; If a verification failure occurs, the data frame corresponding to the verification failure is resent to the storage chip until no verification failure occurs.

4. The method for firmware upgrade as described in claim 3, characterized in that, The method further includes: The upgrade file received in the preset storage area of ​​the memory chip is split into multiple data blocks and copied to the running area of ​​the target hardware. Each data block includes m data frames. Verify each data frame in each data block received in the target hardware's runtime area and output the verification result; If the verification result is that the copying failed, the step of splitting the upgrade file received in the preset storage area of ​​the storage chip into multiple data blocks and copying them to the running area of ​​the target hardware is executed. If the verification result indicates successful copying, a restart command is sent to the target hardware so that the target hardware can restart and run the upgrade file.

5. The method for firmware upgrade as described in claim 1, characterized in that, Sending the upgrade file to the target hardware includes: The upgrade file is split into multiple data blocks and sent to the target hardware, where each data block includes m data frames; Each data frame in each data block received from the target hardware is verified, and the verification result is output, which is either a verification pass result or a verification failure result. If a verification failure occurs, the data frame corresponding to the verification failure is resent to the target hardware until no verification failure occurs.

6. The method for firmware upgrade as described in claim 5, characterized in that, After verifying each data frame in each data block received from the target hardware and outputting the verification result, the method further includes: If the number of failed verification results is greater than or equal to the preset value, an error log is recorded and the upgrade process is terminated.

7. The method for firmware upgrade as described in claim 1, characterized in that, After the target hardware successfully erases the data of the firmware to be upgraded from the backup area, the upgrade file is sent to the target hardware so that the target hardware can write the upgrade file to the backup area. The process also includes: Once the target hardware successfully writes the upgrade file to the backup area, the upgrade file in the target hardware backup area is copied to the runtime area. Verify each data frame in each data block received in the target hardware's runtime area and output the verification result; If the verification result indicates that the copying failed, proceed with the step of copying the upgrade file from the target hardware backup area to the runtime area. If the verification result indicates successful copying, a restart command is sent to the target hardware so that the target hardware can restart and run the upgrade file.

8. An apparatus for implementing firmware upgrades, characterized in that, The apparatus for implementing firmware upgrades includes: Receiving module: Receives the upgrade file of the firmware to be upgraded sent by the host computer based on a general protocol, and determines the target hardware according to the upgrade file, wherein the firmware to be upgraded runs on the target hardware. Sending module: When the target hardware has a communication connection with the MCU, it sends an initialization command to the target hardware to enable the target hardware to enter the upgrade preparation state; after the target hardware enters the upgrade preparation state, it sends an erase command to the target hardware to enable the target hardware to erase the data of the firmware to be upgraded in the backup area; after the target hardware successfully erases the data of the firmware to be upgraded in the backup area, it sends the upgrade file to the target hardware so that the target hardware can write the upgrade file into the backup area.

9. A device for implementing firmware upgrades, characterized in that, The device for implementing firmware upgrades includes a processor, a memory, and a firmware upgrade program stored in the memory and executable by the processor, wherein when the firmware upgrade program is executed by the processor, it implements the steps of the firmware upgrade method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program for implementing firmware upgrades, wherein when the program for implementing firmware upgrades is executed by a processor, it implements the steps of the method for implementing firmware upgrades as described in any one of claims 1 to 7.