Method and system for upgrading microcontroller

By using the CAN communication protocol and identification code management method in the vehicle, parallel upgrades of multiple microcontrollers are realized, which solves the problem of long vehicle microcontroller upgrade time and improves efficiency and user experience.

CN118869474APending Publication Date: 2024-10-29HOZON NEW ENERGY AUTOMOBILE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410778265.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-17
Publication Date
2024-10-29

AI Technical Summary

Technical Problem

When upgrading multiple microcontrollers in a vehicle, existing technology causes the upgrade process to take a long time, affecting work efficiency and user experience.

Method used

CAN communication protocol is adopted, and different identification codes are used to send and respond to upgrade instructions through message transmission between the host computer and the microcontroller to achieve parallel upgrade of multiple microcontrollers.

Benefits of technology

Significantly shortens the time of the microcontroller upgrade process, improves work efficiency and enhances user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118869474A_ABST
    Figure CN118869474A_ABST
Patent Text Reader

Abstract

The invention discloses a microcontroller upgrading method, which is used for upgrading a plurality of microcontrollers with the same function based on a CAN (Controller Area Network), and comprises the following steps: setting an identification code for sending an upgrading instruction for an upper computer; respectively setting an identification code for responding to an upgrading instruction for each microcontroller, and setting an initial value of a state for upgrading of each microcontroller to be available; the upper computer sends an upgrading instruction in a current network domain, the upper computer confirms a response result of each microcontroller in an available state and updates the state of the microcontroller according to the response result, and the step is repeated until all upgrading instructions are sent; and if each microcontroller receives an upgrading instruction, the microcontroller enters a corresponding working mode according to the upgrading instruction until all work is completed. According to the invention, simultaneous parallel upgrading of a plurality of microcontrollers can be realized, the working efficiency is improved, and the improvement of user experience is facilitated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a vehicle microcontroller, and in particular to a method, system, electronic device and medium for upgrading multiple microcontrollers with the same functions. Background Art

[0002] To meet the ever-evolving demands for vehicle functions, the amount of data in vehicles has exploded, and the number of microcontrollers or microcontroller units (MCUs) required for each vehicle has also increased significantly. In actual use, each microcontroller needs to be frequently upgraded to continuously improve its performance.

[0003] Currently, when upgrading multiple microcontrollers in a vehicle, each microcontroller generally obtains its own data packet for upgrading from a host computer (such as a computer or other controller) in the network domain. When the number of microcontrollers is large, this method will cause the vehicle microcontroller upgrade process to take a long time.

[0004] The battery management system (BMS) commonly used in vehicles is generally equipped with different numbers of battery packs. Each battery pack is equipped with a microcontroller to detect battery power, temperature and other parameters. The functions implemented by each microcontroller are essentially the same. If these microcontrollers are upgraded using the existing method, it will seriously affect work efficiency and user experience. Summary of the invention

[0005] Based on the above situation, the main purpose of the present invention is to provide a method, system, electronic device and medium for upgrading a microcontroller, which are used for upgrading multiple microcontrollers with the same functions based on CAN. Based on the characteristics of the CAN communication protocol, the message transmission between the host computer and multiple microcontrollers adopts different identification codes to send and respond to upgrade instructions, so as to realize the simultaneous and parallel upgrading of multiple microcontrollers, which can significantly shorten the time required for the vehicle microcontroller upgrade process, thereby improving work efficiency and enhancing user experience.

[0006] To achieve the above purpose, the technical solution adopted by the present invention is as follows:

[0007] A first aspect of the present invention provides a method for upgrading a microcontroller, which is used for upgrading a plurality of microcontrollers having the same function based on CAN, and the method comprises the following steps:

[0008] Set an identification code for the host computer to send upgrade instructions;

[0009] Setting an identification code for responding to an upgrade instruction for each microcontroller, and setting an initial value of a state for upgrading of each microcontroller to be available;

[0010] The host computer sends an upgrade instruction in the current network domain, the host computer confirms the response result of each microcontroller whose status is available and updates the status of the microcontroller according to the response result, and repeats this step until all the upgrade instructions are sent;

[0011] If each microcontroller receives an upgrade instruction, it enters a corresponding working mode according to the upgrade instruction until all the work is completed.

[0012] Furthermore, the host computer confirms the response result of each microcontroller whose status is available and updates the status of the microcontroller according to the response result, including the following steps:

[0013] If the host computer does not receive a correct response message from a microcontroller within a preset time, the status of the microcontroller is updated to unavailable.

[0014] Furthermore, the host computer confirms the response result of each microcontroller whose status is available and updates the status of the microcontroller according to the response result, and also includes the following steps:

[0015] The host computer records the microcontroller whose status is updated to unavailable as failing to correctly enter the working mode corresponding to the upgrade instruction, and reports the identification code of the microcontroller whose status is updated to unavailable.

[0016] Furthermore, the host computer confirms the response result of each microcontroller whose status is available and updates the status of the microcontroller according to the response result, and also includes the following steps:

[0017] If the host computer does not receive a correct response message from a microcontroller within a preset time, it resends the upgrade instruction according to a preset number of times.

[0018] Further, the upgrade instructions include, in sequence, an upgrade mode entry instruction, an erase instruction, a write instruction, a check instruction, and a reset instruction, and correspond to the upgrade mode, the erase mode, the write mode, the check mode, and the reset mode, respectively;

[0019] If each microcontroller receives an upgrade instruction, it enters a corresponding working mode according to the upgrade instruction, including the following steps:

[0020] If a microcontroller receives the instruction to enter the upgrade mode, it enters the working mode and responds in the current network domain;

[0021] If a microcontroller receives the erase instruction, write instruction, check instruction or reset instruction, it enters the corresponding working mode if the conditions are met, and responds in the current network domain after completing the corresponding work.

[0022] Furthermore, the method comprises the following steps:

[0023] If a microcontroller is in the upgrade mode, it only responds to the erase instruction or reset instruction;

[0024] If a microcontroller is in the erase mode, it only responds to a write command or a reset command;

[0025] If a microcontroller is in the write mode, it only responds to a write instruction, a check instruction or a reset instruction;

[0026] If a microcontroller is in the verification mode, it only responds to the reset instruction;

[0027] If a certain microcontroller is in the reset mode, it is recorded that the upgrade of the microcontroller is completed.

[0028] Furthermore, the method comprises the following steps:

[0029] The microcontroller in the write mode responds to the corresponding write instruction and receives the corresponding data in sequence according to the frame packet sequence number of the data packet.

[0030] A second aspect of the present invention provides a system for upgrading a microcontroller, which is used for upgrading a plurality of microcontrollers having the same functions based on CAN, and the system comprises:

[0031] The first unit is used to set an identification code for sending an upgrade instruction for the host computer, and to set an identification code for responding to the upgrade instruction for each microcontroller, and to set an initial value of the state for upgrading of each microcontroller to be available;

[0032] The second unit is used for the host computer to send an upgrade instruction in the current network domain, the host computer confirms the response result of each microcontroller whose status is available and updates the status of the microcontroller according to the response result, and repeats this step until all the upgrade instructions are sent;

[0033] The third unit is used for each microcontroller to enter a corresponding working mode according to the upgrading instruction if it receives the upgrading instruction until all the work is completed.

[0034] A third aspect of the present invention provides an electronic device, comprising: a processor; and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the method described in the first aspect can be implemented.

[0035] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is used to run to implement the method as described in the first aspect above.

[0036] Compared with the prior art, the present invention has obvious advantages and beneficial effects, and has at least the following advantages:

[0037] The microcontroller upgrade method of the present invention is used for upgrading multiple microcontrollers with the same functions based on CAN. The method is based on the characteristics of the CAN communication protocol. The host computer uses a preset identification code to send an upgrade instruction, and each microcontroller uses a preset identification code to respond to the upgrade instruction, wherein the identification code of the host computer is different from the identification code of each microcontroller, and the identification code of each microcontroller is also different. Therefore, the host computer can distinguish which microcontroller's response message is based on the received message data, and effectively and timely manage the upgrade work of the microcontrollers in the network domain. The method can realize the simultaneous and parallel upgrade of multiple microcontrollers, which can significantly shorten the time required for the upgrade process of multiple microcontrollers, thereby improving work efficiency and helping to improve user experience.

[0038] The microcontroller upgrade system of the present invention is used for upgrading multiple microcontrollers with the same functions based on CAN. By utilizing the characteristics of the CAN communication protocol, the host computer and each microcontroller use a preset identification code to send and respond to upgrade instructions, wherein the identification code of the host computer is different from the identification code of each microcontroller, and the identification code of each microcontroller is also different. Therefore, the host computer can distinguish which microcontroller's response message is based on the received message data. The system can realize the simultaneous and parallel upgrading of multiple microcontrollers, which can significantly shorten the time required for the upgrading process of multiple microcontrollers, thereby improving work efficiency and helping to improve user experience.

[0039] The electronic device and computer-readable storage medium of the present invention can realize the simultaneous and parallel upgrading of multiple microcontrollers by adopting the above method, which can significantly shorten the time required for the upgrading process of multiple microcontrollers, improve work efficiency and enhance user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 A schematic diagram of a preferred embodiment of the method of the present invention;

[0041] Figure 2 A schematic diagram of a network topology of a battery management system according to an embodiment of the present invention;

[0042] Figure 3A schematic diagram of a flow chart of a host computer sending an upgrade instruction in a preferred embodiment of the method of the present invention;

[0043] Figure 4 A schematic diagram of the working mode of a microcontroller according to a preferred embodiment of the method of the present invention;

[0044] Figure 5 The module diagram of a preferred embodiment of the system of the present invention is shown in FIG. DETAILED DESCRIPTION

[0045] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined purpose of the invention, the following is a detailed description of the method, system, electronic device and computer-readable storage medium proposed in the present invention, its specific implementation method, method, steps, features and effects, in combination with the accompanying drawings and preferred embodiments.

[0046] See also Figure 1 A method for upgrading a microcontroller is used for upgrading a plurality of microcontrollers having the same function based on CAN, the method comprising the following steps:

[0047] S100, setting an identification code for the host computer to send an upgrade instruction;

[0048] S200, setting an identification code for responding to an upgrade instruction for each microcontroller, and setting an initial value of a state for upgrading of each microcontroller to be available;

[0049] S300, the host computer sends an upgrade instruction in the current network domain, the host computer confirms the response result of each microcontroller in an available state and updates the state of the microcontroller according to the response result, and repeats this step until all upgrade instructions are sent;

[0050] S400, if each microcontroller receives an upgrade instruction, it enters a corresponding working mode according to the upgrade instruction until all the work is completed.

[0051] See also Figure 2, the CAN-based host computer and multiple microcontrollers are connected through the CAN bus, where the CAN bus can be a controller area network bus (Controller Area Network, abbreviated as CAN) or a controller area network bus with a variable rate (CAN with Flexible Data rate, abbreviated as CAN FD); the host computer (Host) can be, for example, a computer or other controller. Based on the characteristics of the CAN communication protocol, in the CAN network domain, the messages sent by different devices can be received by all other devices in the current network domain. Therefore, the messages sent by the host computer can be received by all microcontrollers, and the microcontrollers that receive the messages can make corresponding responses based on the messages.

[0052] Specifically, regarding step S100, an identification code (ID) dedicated to sending an upgrade instruction is set for the host computer, and the identification code is used for the message of CAN communication.

[0053] Regarding step S200, an identification code for responding to the upgrade instruction is set for each microcontroller, each identification code corresponds to a microcontroller, and each identification code is different from the identification code of the host computer. The identification codes of all microcontrollers can be pre-recorded on a storage medium, such as a data flash (Data Flash) or an electrically erasable programmable read-only memory (EEROM). After power-on, each microcontroller can read its own corresponding identification code from the storage medium for use in the message of responding to the upgrade instruction. When upgrading, the status for upgrading of all microcontrollers in the current network domain can be initialized to available, and the host computer in the current network domain has the number information of microcontrollers and the corresponding identification codes of these microcontrollers.

[0054] Regarding step S300, the upgrade instruction includes multiple instructions with a sequential relationship, and the host computer sends multiple instructions in sequence to command the microcontroller to enter different working modes in steps and complete the work. For example, the upgrade instruction sent by the host computer includes an upgrade mode entry instruction, an erase instruction, a write instruction, a check instruction, and a reset instruction in sequence. Accordingly, after receiving the upgrade instruction, the microcontroller can enter the corresponding working mode, that is, enter the upgrade mode, erase mode, write mode, check mode, and reset mode.

[0055] Each time the host computer sends an upgrade command in the network domain, it needs to wait for the response message of all microcontrollers whose current status is available to the upgrade command. If the host computer receives a correct response message from a microcontroller, it considers that the microcontroller is in normal working mode and does not need to update its status. If the host computer does not receive a correct response message from a microcontroller, it updates the status of the microcontroller to unavailable, and considers that the microcontroller does not exist in the subsequent upgrade process, that is, the microcontroller does not participate in this upgrade. When the host computer confirms the response result of the microcontroller whose current status is available when sending the upgrade command, it will send the next order of upgrade commands and confirm the corresponding response result according to the updated available microcontroller status.

[0056] Regarding step S400, each microcontroller enters a corresponding working mode after correctly receiving a certain upgrade instruction, completes corresponding work in the working mode and responds with a corresponding identification code so that the upper computer can know the status of the microcontroller.

[0057] Through the above steps, multiple microcontrollers with the same functions can be upgraded based on CAN. By utilizing the characteristics of the CAN communication protocol, the host computer uses a preset identification code to send an upgrade instruction, and each microcontroller uses a preset identification code to respond to the upgrade instruction, wherein the identification code of the host computer is different from the identification code of each microcontroller, and the identification code of each microcontroller is also different. Therefore, the host computer can distinguish which microcontroller's response message is based on the received message data, and effectively and timely manage the upgrade work of the microcontrollers in the network domain, so that multiple microcontrollers can be upgraded in parallel in the current network domain at the same time, which can significantly shorten the time required for the upgrade process of multiple microcontrollers.

[0058] As an optional embodiment, S300, the host computer confirms the response result of each microcontroller whose status is available and updates the status of the microcontroller according to the response result, including the following steps:

[0059] S310: If the host computer does not receive a correct response message from a microcontroller within a preset time, the status of the microcontroller is updated to unavailable.

[0060] Specifically, each time the upper computer sends an upgrade instruction in the current network domain, it needs to wait for the response messages of all microcontrollers whose status is available at the current moment to determine whether the status of all microcontrollers to be upgraded in the network domain can continue to be upgraded. If a microcontroller fails to respond correctly to the upgrade instruction within the preset time, the upper computer believes that the microcontroller has failed to enter the working mode corresponding to the upgrade instruction and cannot perform subsequent upgrade work. Accordingly, the status record of the microcontroller is updated to unavailable, and it will no longer participate in this upgrade. In other words, the upper computer does not need to wait for the corresponding response message of the microcontroller after sending the upgrade instruction next time.

[0061] It should be noted that the preset time of different upgrade instructions may be different, which can be set according to the work content required by the microcontroller to complete the upgrade instruction. For example, the preset time corresponding to the instruction to enter the upgrade mode may be 100ms, the preset time corresponding to the erase instruction may be 6s, the preset time corresponding to the write instruction may be 300ms, the preset time corresponding to the verification instruction may be 5s, and the preset time corresponding to the reset instruction may be 1s. In addition, the preset waiting time corresponding to each upgrade instruction is also related to the capacity of the microcontroller. The time in the above example is generally based on the capacity of the microcontroller of about 1MB. If the capacity reaches 2MB, the preset time also needs to be increased accordingly, for example, from the original 5s to 10s.

[0062] Through the above steps, after each upgrade instruction is sent, the host computer can timely update the status of the microcontroller according to the response result of the microcontroller and determine whether each microcontroller continues to participate in the upgrade. While realizing the simultaneous upgrade of multiple microcontrollers, it can also help reduce the time the host computer waits for the microcontroller's response message, which can effectively improve the upgrade work efficiency.

[0063] As an optional embodiment, S300, the host computer confirms the response result of each microcontroller whose status is available and updates the status of the microcontroller according to the response result, and also includes the following steps:

[0064] S320, the host computer records the microcontroller whose status is updated to unavailable as failing to correctly enter the working mode corresponding to the upgrade instruction, and reports the identification code of the microcontroller whose status is updated to unavailable.

[0065] Specifically, each time the host computer sends an upgrade instruction in the current network domain and determines the status of all microcontrollers to be upgraded in the network domain, the host computer updates the status to unavailable microcontrollers for reporting. For example, the host computer can report and print out the identification code of the microcontroller that no longer participates in the upgrade in the serial port.

[0066] Through the above steps, the microcontrollers that do not participate in the upgrade are output, so that these microcontrollers that do not participate in the upgrade can be known in time and further checked whether there are version problems or hardware damage problems.

[0067] As an optional embodiment, S300, the host computer confirms the response result of each microcontroller whose status is available and updates the status of the microcontroller according to the response result, and also includes the following steps:

[0068] S330: If the host computer does not receive a correct response message from a microcontroller within a preset time, it resends the upgrade instruction according to a preset number of times.

[0069] Specifically, if a microcontroller fails to respond correctly to the upgrade instruction within the preset time, the host computer will resend the upgrade instruction according to the preset number of times (for example, 3 times). If the microcontroller still fails to respond correctly, the host computer believes that the microcontroller has failed to enter the working mode corresponding to the upgrade instruction and cannot perform subsequent upgrade work. Accordingly, the status record of the microcontroller is updated to unavailable, and it will no longer participate in this upgrade.

[0070] Through the above steps, taking into account the actual communication conditions of the network, the microcontroller is allowed to make a correct response to the upgrade instruction within a preset time and a preset number of times, so as to achieve simultaneous upgrade of multiple microcontrollers that meet the conditions as much as possible, which helps to improve work efficiency.

[0071] As an optional embodiment, the upgrade instruction includes an upgrade mode entry instruction, an erase instruction, a write instruction, a check instruction and a reset instruction in sequence, and corresponds to the upgrade mode, the erase mode, the write mode, the check mode and the reset mode respectively;

[0072] S400, if each microcontroller receives an upgrade instruction, it enters a corresponding working mode according to the upgrade instruction, including the following steps:

[0073] S410, if a microcontroller receives the instruction to enter the upgrade mode, it enters the working mode and responds in the current network domain;

[0074] S420, if a microcontroller receives the erase instruction, write instruction, check instruction or reset instruction, it enters the corresponding working mode if the conditions are met, and responds in the current network domain after completing the corresponding work.

[0075] Specifically, as described in S300, the upgrade instruction includes a plurality of instructions having a sequential relationship, and the host computer sends the plurality of instructions in sequence to instruct the microcontroller to enter different working modes in steps and complete the work.

[0076] Among them, regarding step S410, if the upgrade instruction received by a microcontroller is an instruction to enter the upgrade mode, the microcontroller makes corresponding preparations and enters the upgrade mode within the corresponding preset time (for example, 10ms), and the microcontroller uses its own corresponding identification code to make a correct response in the current network domain. The above work needs to be completed within the preset time (for example, 100ms) to reply to the host computer that its status is available and can continue to participate in subsequent upgrade steps.

[0077] Regarding step S420, if the upgrade instruction received by a microcontroller is an erase instruction, a write instruction, a verification instruction or a reset instruction, the microcontroller determines whether it should enter the working mode corresponding to the upgrade instruction based on the current working mode of the microcontroller. After entering the corresponding working mode, it needs to complete the work specified by the working mode. After completing the corresponding work, it responds in the current network domain to reply its status to the host computer.

[0078] For example, if the microcontroller receives an erase instruction, the erase time required for each microcontroller will also be different, considering the differences between the microcontrollers and the size of the erase area. Generally speaking, 2 seconds should be enough to complete the erase work. Therefore, after receiving the erase instruction, a microcontroller needs to complete the erase work within the corresponding preset time (for example, 2 seconds), and the microcontroller uses its own corresponding identification code to make a correct response in the current network domain. The above work needs to be completed within the preset time (for example, 6 seconds) to reply to the host computer that the erase has been completed and can continue to participate in the subsequent upgrade steps.

[0079] If the microcontroller receives a write instruction, each write instruction is used to write a frame of data (usually 1024 bytes) to the flash memory, and each frame of data contains a sequence number corresponding to the frame. Therefore, after receiving the write instruction, a microcontroller needs to complete the flash memory write work within the corresponding preset time (e.g. 100ms), and the microcontroller uses its own corresponding identification code to make a correct response in the current network domain. The above work needs to be completed within the preset time (e.g. 300ms) to reply to the host computer that the write has been completed and can continue to participate in the subsequent upgrade steps.

[0080] If a microcontroller receives a verification instruction, the microcontroller needs to complete the flash memory verification within the corresponding preset time (for example, 4s) after receiving the verification instruction, and the microcontroller needs to use its own corresponding identification code to make a correct response in the current network domain. The above work needs to be completed within the preset time (for example, 5s) to reply to the host computer that the verification has been completed and can continue to participate in subsequent upgrade steps.

[0081] If a microcontroller receives a reset instruction, the microcontroller will reset after receiving the reset instruction, and the microcontroller will upgrade the success status to the data flash memory or electrically erasable programmable read-only memory, and the microcontroller will use its own corresponding identification code to send the data to be uploaded to the CAN bus in the current network domain. The above work needs to be completed within a preset time (for example 1s).

[0082] Through the above steps, after receiving different upgrade instructions, the microcontroller completes the corresponding work according to the current state or working mode, and responds to the host computer, so that the host computer can know the status of each microcontroller in time, and thereby determine whether the next upgrade step can be performed.

[0083] As an optional embodiment, the method further includes the following steps:

[0084] If a microcontroller is in the upgrade mode, it only responds to the erase instruction or reset instruction;

[0085] If a microcontroller is in the erase mode, it only responds to a write command or a reset command;

[0086] If a microcontroller is in the write mode, it only responds to a write instruction, a check instruction or a reset instruction;

[0087] If a microcontroller is in the verification mode, it only responds to the reset instruction;

[0088] If a certain microcontroller is in the reset mode, it is recorded that the upgrade of the microcontroller is completed.

[0089] As a further improvement of the above embodiment, the method further includes the following steps:

[0090] The microcontroller in the write mode responds to the corresponding write instruction and receives the corresponding data in sequence according to the frame packet sequence number of the data packet.

[0091] Specifically, considering the multiple steps in the upgrade process, the microcontroller may respond to different upgrade instructions in different working modes.

[0092] For example, the microcontroller is in the upgrade mode and only responds to the erase command or reset command, does not respond to other commands, and will not respond to the resent upgrade mode command.

[0093] The microcontroller is in erase mode and only responds to write commands or reset commands. It does not respond to other commands and will not respond to resent erase commands.

[0094] The microcontroller is in write mode and only responds to write instructions, check instructions or reset instructions, and does not respond to any other instructions. For write instructions, the microcontroller performs corresponding operations according to the sequence number of the frame. The sequence number of the frame is generally sequentially increased by 1. Therefore, the microcontroller receives the write instruction according to the sequence number of the frame and performs corresponding flash memory writes. It no longer receives data frames that have been written and will not respond to resent write instructions.

[0095] The microcontroller is in verification mode and only responds to reset instructions. It does not respond to any other instructions and will not respond to resent verification instructions.

[0096] The microcontroller is in reset mode, records the upgrade success status in the data flash memory or the electrically erasable programmable read-only memory, and uses its own corresponding identification code to send the data to be uploaded to the CAN bus in the current network domain, thereby confirming that the microcontroller upgrade is completed.

[0097] Through the above steps, after receiving different upgrade instructions, the microcontroller determines whether it should enter the working mode corresponding to the upgrade instruction according to the current working mode. In different working modes, it only responds to certain upgrade instructions and does not respond to repeatedly received instructions, so as to ensure that multiple upgrade steps are executed in the correct order.

[0098] Specifically, see Figure 3 The host computer sends the upgrade mode entry command, erase command, write command, verify command and reset command in sequence, and after sending each upgrade command, it confirms the status of each microcontroller according to its response result before sending the next step of command. Figure 4 Each microcontroller determines whether to respond and complete the corresponding work according to the received upgrade instruction and the current working mode. The above process of the host computer and microcontroller can realize the simultaneous parallel upgrade of multiple microcontrollers with the same function.

[0099] See also Figure 5 , a microcontroller upgrade system, used for upgrading multiple microcontrollers with the same function based on CAN, the system comprising:

[0100] The first unit is used to set an identification code for sending an upgrade instruction for the host computer, and to set an identification code for responding to the upgrade instruction for each microcontroller, and to set an initial value of the state for upgrading of each microcontroller to be available;

[0101] The second unit is used for the host computer to send an upgrade instruction in the current network domain, the host computer confirms the response result of each microcontroller whose status is available and updates the status of the microcontroller according to the response result, and repeats this step until all the upgrade instructions are sent;

[0102] The third unit is used for each microcontroller to enter a corresponding working mode according to the upgrading instruction if it receives the upgrading instruction until all the work is completed.

[0103] Therefore, multiple microcontrollers with the same functions are upgraded based on CAN. Utilizing the characteristics of the CAN communication protocol, the host computer and each microcontroller use pre-set identification codes to send and respond to upgrade instructions, wherein the identification code of the host computer is different from the identification code of each microcontroller, and the identification code of each microcontroller is also different. Therefore, the host computer can distinguish which microcontroller's response message is based on the received message data. The system can realize the simultaneous and parallel upgrading of multiple microcontrollers, which can significantly shorten the time required for the upgrading process of multiple microcontrollers, thereby improving work efficiency and helping to improve user experience.

[0104] The present invention further provides an electronic device, comprising: a processor; and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the method described in the above embodiment can be implemented.

[0105] The present invention further provides a computer-readable storage medium on which a computer program is stored. The computer program is used to run to implement the method described in the above embodiment.

[0106] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment as above, it is not used to limit the present invention. Any technician familiar with this profession can make some changes or modifications to equivalent embodiments of equivalent changes using the technical contents disclosed above without departing from the scope of the technical solution of the present invention. However, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention still falls within the scope of the technical solution of the present invention.

Claims

1. A method for upgrading a microcontroller, for upgrading a plurality of microcontrollers with the same function based on CAN, characterized in that: The method comprises the following steps: Set an identification code for the host computer to send upgrade instructions; Setting an identification code for responding to an upgrade instruction for each microcontroller, and setting an initial value of a state for upgrading of each microcontroller to be available; The host computer sends an upgrade instruction in the current network domain, the host computer confirms the response result of each microcontroller whose status is available and updates the status of the microcontroller according to the response result, and repeats this step until all the upgrade instructions are sent; If each microcontroller receives an upgrade instruction, it enters a corresponding working mode according to the upgrade instruction until all the work is completed.

2. The method according to claim 1, characterized in that The host computer confirms the response result of each microcontroller that is in an available state and updates the state of the microcontroller according to the response result, including the following steps: If the host computer does not receive a correct response message from a microcontroller within a preset time, the status of the microcontroller is updated to unavailable.

3. The method according to claim 2, characterized in that The host computer confirms the response result of each microcontroller in an available state and updates the state of the microcontroller according to the response result, and also includes the following steps: The host computer records the microcontroller whose status is updated to unavailable as failing to correctly enter the working mode corresponding to the upgrade instruction, and reports the identification code of the microcontroller whose status is updated to unavailable.

4. The method according to claim 1, characterized in that The host computer confirms the response result of each microcontroller in an available state and updates the state of the microcontroller according to the response result, and also includes the following steps: If the host computer does not receive a correct response message from a microcontroller within a preset time, it resends the upgrade instruction according to a preset number of times.

5. The method according to claim 1, characterized in that The upgrade instructions include an upgrade mode entry instruction, an erase instruction, a write instruction, a check instruction and a reset instruction in sequence, and correspond to the upgrade mode, the erase mode, the write mode, the check mode and the reset mode respectively; If each microcontroller receives an upgrade instruction, it enters a corresponding working mode according to the upgrade instruction, including the following steps: If a microcontroller receives the instruction to enter the upgrade mode, it enters the working mode and responds in the current network domain; If a microcontroller receives the erase instruction, write instruction, check instruction or reset instruction, it enters the corresponding working mode if the conditions are met, and responds in the current network domain after completing the corresponding work.

6. The method according to claim 5, characterized in that The steps include: If a microcontroller is in the upgrade mode, it only responds to the erase instruction or reset instruction; If a microcontroller is in the erase mode, it only responds to a write command or a reset command; If a microcontroller is in the write mode, it only responds to a write instruction, a check instruction or a reset instruction; If a microcontroller is in the verification mode, it only responds to the reset instruction; If a certain microcontroller is in the reset mode, it is recorded that the upgrade of the microcontroller is completed.

7. The method according to claim 6, characterized in that The steps include: The microcontroller in the write mode responds to the corresponding write instruction and receives the corresponding data in sequence according to the frame packet sequence number of the data packet.

8. A microcontroller upgrade system, used for upgrading multiple microcontrollers with the same functions based on CAN, characterized in that: The system comprises: The first unit is used to set an identification code for sending an upgrade instruction for the host computer, and to set an identification code for responding to the upgrade instruction for each microcontroller, and to set an initial value of the state for upgrading of each microcontroller to be available; The second unit is used for the host computer to send an upgrade instruction in the current network domain, the host computer confirms the response result of each microcontroller whose status is available and updates the status of the microcontroller according to the response result, and repeats this step until all the upgrade instructions are sent; The third unit is used for each microcontroller to enter a corresponding working mode according to the upgrading instruction if it receives the upgrading instruction until all the work is completed.

9. An electronic device, characterized in that: include: processor; as well as A memory having a computer program stored thereon, wherein the computer program, when executed by the processor, can implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer program is used to run to implement the method according to any one of claims 1 to 7.