Broadcast upgrading method and system based on CAN2.0B protocol and storage medium
By adopting a broadcast upgrade method based on the CAN2.0B protocol, parallel upgrades of identical modules in embedded devices were achieved, solving the problems of low efficiency and cumbersome steps in the existing technology, improving upgrade efficiency and simplifying operation.
Patent Information
- Application Number
- CN202411569128.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-01-10
AI Technical Summary
In existing technologies, when an embedded device integrates multiple identical modules, the CAN point-to-point upgrade method is inefficient and involves cumbersome steps.
A broadcast upgrade method based on the CAN2.0B protocol is adopted. The main chip sends a broadcast upgrade synchronization notification, sends firmware data in segments, and performs verification at the receiving end to ensure that all module chips are upgraded in parallel.
It enables parallel upgrades of identical modules, improves upgrade efficiency, simplifies upgrade steps, ensures controllable data transmission timing, and supports data self-verification.
Smart Images

Figure CN119292636A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of broadcast upgrade, and in particular to a broadcast upgrade method, system and storage medium based on CAN2.0B protocol. Background Art
[0002] Embedded devices contain multiple CPUs / MCUs, and the chips communicate with each other via the CAN bus. In general, the main CPU / MCU is designed to provide external communication methods such as network ports or serial ports, so that the main chip can be directly upgraded. Other chips require the main chip to cache the firmware upgrade and then complete the point-to-point upgrade via CAN. If an embedded device integrates multiple modules of the same type, the CAN point-to-point upgrade method will be inefficient and the upgrade steps will be cumbersome. Summary of the invention
[0003] The purpose of the present invention is to overcome the deficiencies of the prior art and to provide a broadcast upgrade method, system and storage medium based on the CAN2.0B protocol.
[0004] The object of the present invention is achieved through the following technical solutions: The first aspect of the present invention provides: a broadcast upgrade method based on the CAN2.0B protocol, comprising the following steps: Step 1: The main chip sends a broadcast upgrade synchronization notification and repeats it for a preset number of times to ensure that other module chips enter the broadcast upgrade mode. At this time, it is forbidden to send CAN data arbitration to compete for the bus, initialize the upgrade environment, and other module chips wait to receive broadcast firmware data; Step 2: The main chip pre-processes the module firmware. The size of the module firmware must be an integer multiple of 8 bytes. Otherwise, 0xFF is filled at the end of the module firmware to make it complete. Step 3: The main chip calculates the checksum of the pre-processed module firmware; Step 4: The main chip fragments the pre-processed module firmware into 8 bytes, with the fragment number starting from 0. The fragment number is filled with the data transmission unit ID, and the data segment is filled with fragment data. The fragment data frame is sent to other module chips in turn. The interval between fragment data frame transmission must be greater than the single-chip data frame transmission processing and storage delay; Step 5: After all module firmware fragments are sent, the main chip sends a broadcast upgrade verification. The verification data segment is the verification word calculated in step 3. The module chip receives the verification word and verifies the received and stored firmware data. If the verification is correct, the module firmware is upgraded. Otherwise, the upgrade data is ignored. Step 6: The main chip sends a broadcast upgrade exit message. After receiving the message, all module chips exit the upgrade mode and enter the normal working mode. The module chips resume sending CAN data. If the module chips are successfully upgraded, they determine whether to restart according to the upgrade strategy.
[0005] Preferably, the preset number of times is 5 times.
[0006] Preferably, a standard data frame is used as a control transmission unit, and an extended data frame is used as a data transmission unit.
[0007] Preferably, the standard data frame has IDE=0, RTR=0, the extended data frame has IDE=1, RTR=0, and the upper limit of the data segment length of the standard data frame and the extended data frame is 8 bytes.
[0008] Preferably, the control transmission unit is used to complete the firmware upgrade timing control, the control transmission unit ID is 11 bits, and the control transmission unit ID is used to define the control message type of the CAN broadcast upgrade. Preferably, the control message types include broadcast upgrade synchronization notification, broadcast upgrade verification, and broadcast upgrade exit.
[0009] Preferably, the data transmission unit is used to complete firmware data transmission, and the data transmission unit ID is 29 bits, which is used to identify the data frame sequence number.
[0010] Preferably, the check word is a CRC32 check word.
[0011] The second aspect of the present invention provides: a broadcast upgrade system based on the CAN2.0B protocol, used to implement any of the above-mentioned broadcast upgrade methods based on the CAN2.0B protocol, comprising: Initialize the upgrade environment module, which is used to use the main chip to send broadcast upgrade synchronization notifications, repeat the preset number of times, and ensure that other module chips enter the broadcast upgrade mode. At this time, it is forbidden to send CAN data arbitration to compete for the bus, initialize the upgrade environment, and other module chips wait to receive broadcast firmware data; The preprocessing module is used to preprocess the module firmware using the main chip. The size of the module firmware must be an integer multiple of 8 bytes, otherwise 0xFF is filled at the end of the module firmware to make it complete. A check word calculation module, used to calculate a check word for the pre-processed module firmware using a main chip; The fragmented data sending module is used to use the main chip to fragment the pre-processed module firmware into 8 bytes. The fragment number starts from 0, and the fragment number is filled with the data transmission unit ID. The data segment is filled with fragment data. The fragment data frame is sent to other module chips in sequence. The fragment data frame sending interval must be greater than the single-chip data frame transmission processing and storage delay; The verification module is used to send a broadcast upgrade verification after the fragmented data of all module firmware is sent. The main chip sends a broadcast upgrade verification. The verification data segment is the verification word calculated by the verification word calculation module. The module chip receives the verification word and verifies the received and stored firmware data. If the verification is correct, the firmware of this module is upgraded, otherwise, the upgrade data is ignored; the main chip sends a broadcast upgrade exit message. After all module chips receive the message, they exit the upgrade mode and enter the normal working mode. The module chip resumes sending CAN data. If the module chip is successfully upgraded, it determines whether to restart according to the upgrade strategy.
[0012] The third aspect of the present invention provides: a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by a processor, any of the above-mentioned broadcast upgrade methods based on the CAN2.0B protocol is implemented.
[0013] The beneficial effects of the present invention are: 1) During the broadcast upgrade, the main chip only sends data, and other chips only receive data; the data sending timing is controllable, and the algorithm is designed with enough gaps to ensure that other chips complete the upgrade data storage; support parallel upgrade of the same type of modules to improve efficiency; other chips complete data self-verification, and the firmware is updated after verification. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 The figure is a flow chart of the broadcast upgrade method based on the CAN2.0B protocol. DETAILED DESCRIPTION
[0015] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0016] See also Figure 1 The first aspect of the present invention provides: a broadcast upgrade method based on the CAN2.0B protocol, comprising the following steps: Step 1: The main chip sends a broadcast upgrade synchronization notification and repeats it for a preset number of times to ensure that other module chips enter the broadcast upgrade mode. At this time, it is forbidden to send CAN data arbitration to compete for the bus, initialize the upgrade environment, and other module chips wait to receive broadcast firmware data; Step 2: The main chip pre-processes the module firmware. The size of the module firmware must be an integer multiple of 8 bytes. Otherwise, 0xFF is filled at the end of the module firmware to make it complete. Step 3: The main chip calculates the checksum of the pre-processed module firmware; Step 4: The main chip fragments the pre-processed module firmware into 8 bytes, with the fragment number starting from 0. The fragment number is filled with the data transmission unit ID, and the data segment is filled with fragment data. The fragment data frame is sent to other module chips in turn. The interval between fragment data frame transmission must be greater than the single-chip data frame transmission processing and storage delay; Step 5: After all module firmware fragments are sent, the main chip sends a broadcast upgrade verification. The verification data segment is the verification word calculated in step 3. The module chip receives the verification word and verifies the received and stored firmware data. If the verification is correct, the module firmware is upgraded. Otherwise, the upgrade data is ignored. Step 6: The main chip sends a broadcast upgrade exit message. After receiving the message, all module chips exit the upgrade mode and enter the normal working mode. The module chips resume sending CAN data. If the module chips are successfully upgraded, they determine whether to restart according to the upgrade strategy.
[0017] In some embodiments, the preset number of times is 5 times.
[0018] In some embodiments, a standard data frame is used as a control transmission unit, and an extended data frame is used as a data transmission unit.
[0019] In this embodiment, the present invention is based on the CAN2.0B protocol, uses a standard data frame (IDE=0, RTR=0) as a control transmission unit, and uses an extended data frame (IDE=1, RTR=0) as a data transmission unit. The upper limit of the data segment length of both formats is 8 bytes. The CAN2.0B protocol frame format is shown in Table 1.
[0020] Table 1 In some embodiments, the standard data frame has IDE=0, RTR=0, the extended data frame has IDE=1, RTR=0, and the upper limit of the data segment length of the standard data frame and the extended data frame is 8 bytes.
[0021] In some embodiments, the control transmission unit is used to complete the firmware upgrade timing control, the control transmission unit ID is 11 bits, and the control transmission unit ID is used to define the control message type of the CAN broadcast upgrade.
[0022] In this embodiment, the control transmission unit completes the firmware upgrade timing control. The control transmission unit ID is 11 bits, and the ID defines the control message type of the CAN broadcast upgrade: broadcast upgrade synchronization notification, broadcast upgrade verification, and broadcast upgrade exit. The frame format of the control transmission unit is shown in Table 2.
[0023] Table 2 In some embodiments, the control message types include broadcast upgrade synchronization notification, broadcast upgrade verification, and broadcast upgrade exit.
[0024] In some embodiments, the data transmission unit is used to complete firmware data transmission, and the data transmission unit ID is 29 bits, which is used to identify the data frame sequence number.
[0025] In this embodiment, the data transmission unit is used to complete the firmware data transmission. The data transmission unit ID is 29 bits, which is used to identify the data frame sequence number, starting from 0. The upper limit of a single frame data is 8 bytes, so it theoretically supports the module to upgrade the maximum 4GB firmware. The frame format of the data transmission unit is shown in Table 3.
[0026] Table 3 In some embodiments, the check word is a CRC32 check word.
[0027] The second aspect of the present invention provides: a broadcast upgrade system based on the CAN2.0B protocol, used to implement any of the above-mentioned broadcast upgrade methods based on the CAN2.0B protocol, comprising: Initialize the upgrade environment module, which is used to use the main chip to send broadcast upgrade synchronization notifications, repeat the preset number of times, and ensure that other module chips enter the broadcast upgrade mode. At this time, it is forbidden to send CAN data arbitration to compete for the bus, initialize the upgrade environment, and other module chips wait to receive broadcast firmware data; The preprocessing module is used to preprocess the module firmware using the main chip. The size of the module firmware must be an integer multiple of 8 bytes, otherwise 0xFF is filled at the end of the module firmware to make it complete. A check word calculation module, used to calculate a check word for the pre-processed module firmware using a main chip; The fragmented data sending module is used to use the main chip to fragment the pre-processed module firmware into 8 bytes. The fragment number starts from 0, and the fragment number is filled with the data transmission unit ID. The data segment is filled with fragment data. The fragment data frame is sent to other module chips in sequence. The fragment data frame sending interval must be greater than the single-chip data frame transmission processing and storage delay; The verification module is used to send a broadcast upgrade verification after the fragmented data of all module firmware is sent. The main chip sends a broadcast upgrade verification. The verification data segment is the verification word calculated by the verification word calculation module. The module chip receives the verification word and verifies the received and stored firmware data. If the verification is correct, the firmware of this module is upgraded, otherwise, the upgrade data is ignored; the main chip sends a broadcast upgrade exit message. After all module chips receive the message, they exit the upgrade mode and enter the normal working mode. The module chip resumes sending CAN data. If the module chip is successfully upgraded, it determines whether to restart according to the upgrade strategy.
[0028] The third aspect of the present invention provides: a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by a processor, any of the above-mentioned broadcast upgrade methods based on the CAN2.0B protocol is implemented.
[0029] The above is only a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the form disclosed herein, and should not be regarded as excluding other embodiments, but can be used in various other combinations, modifications and environments, and can be modified within the scope of the concept described herein through the above teachings or the technology or knowledge of the relevant field. The changes and modifications made by those skilled in the art shall not deviate from the spirit and scope of the present invention, and shall be within the scope of protection of the claims attached to the present invention.
Claims
1. A broadcast upgrade method based on CAN2.0B protocol, characterized in that: The following steps are involved: Step 1: The main chip sends a broadcast upgrade synchronization notification and repeats it for a preset number of times to ensure that other module chips enter the broadcast upgrade mode. At this time, it is forbidden to send CAN data arbitration to compete for the bus, initialize the upgrade environment, and other module chips wait to receive broadcast firmware data; Step 2: The main chip pre-processes the module firmware. The size of the module firmware must be an integer multiple of 8 bytes. Otherwise, 0xFF is filled at the end of the module firmware to make it complete. Step 3: The main chip calculates the checksum of the pre-processed module firmware; Step 4: The main chip fragments the pre-processed module firmware into 8 bytes, with the fragment number starting from 0. The fragment number is filled with the data transmission unit ID, and the data segment is filled with fragment data. The fragment data frame is sent to other module chips in turn. The interval between fragment data frame transmission must be greater than the single-chip data frame transmission processing and storage delay; Step 5: After all module firmware fragments are sent, the main chip sends a broadcast upgrade verification. The verification data segment is the verification word calculated in step 3. The module chip receives the verification word and verifies the received and stored firmware data. If the verification is correct, the module firmware is upgraded. Otherwise, the upgrade data is ignored. Step 6: The main chip sends a broadcast upgrade exit message. After receiving the message, all module chips exit the upgrade mode and enter the normal working mode. The module chips resume sending CAN data. If the module chips are successfully upgraded, they determine whether to restart according to the upgrade strategy.
2. The broadcast upgrade method based on CAN2.0B protocol according to claim 1 is characterized in that: The preset number of times is 5 times.
3. The broadcast upgrade method based on CAN2.0B protocol according to claim 1 is characterized in that: Use standard data frames as control transmission units and use extended data frames as data transmission units.
4. The broadcast upgrade method based on CAN2.0B protocol according to claim 3 is characterized in that: The standard data frame has IDE=0 and RTR=0, and the extended data frame has IDE=1 and RTR=0. The upper limit of the data segment length of the standard data frame and the extended data frame is 8 bytes.
5. The broadcast upgrade method based on CAN2.0B protocol according to claim 3 is characterized in that: The control transmission unit is used to complete the firmware upgrade timing control. The control transmission unit ID is 11 bits, and the control transmission unit ID is used to define the control message type of the CAN broadcast upgrade.
6. The broadcast upgrade method based on CAN2.0B protocol according to claim 5 is characterized in that: The control message types include broadcast upgrade synchronization notification, broadcast upgrade verification, and broadcast upgrade exit.
7. The broadcast upgrade method based on CAN2.0B protocol according to claim 3 is characterized in that: The data transmission unit is used to complete firmware data transmission, and the data transmission unit ID is 29 bits, which is used to identify the data frame sequence number.
8. The broadcast upgrade method based on CAN2.0B protocol according to any one of claims 1 to 7, characterized in that: The check word is a CRC32 check word.
9. A broadcast upgrade system based on CAN2.0B protocol, characterized in that: The method for implementing the broadcast upgrade method based on the CAN2.0B protocol as claimed in any one of claims 1 to 8 comprises: Initialize the upgrade environment module, which is used to use the main chip to send broadcast upgrade synchronization notifications, repeat the preset number of times, and ensure that other module chips enter the broadcast upgrade mode. At this time, it is forbidden to send CAN data arbitration to compete for the bus, initialize the upgrade environment, and other module chips wait to receive broadcast firmware data; The preprocessing module is used to preprocess the module firmware using the main chip. The size of the module firmware must be an integer multiple of 8 bytes, otherwise 0xFF is filled at the end of the module firmware to make it complete. A check word calculation module, used to calculate a check word for the pre-processed module firmware using a main chip; The fragmented data sending module is used to use the main chip to fragment the pre-processed module firmware into 8 bytes. The fragment number starts from 0, and the fragment number is filled with the data transmission unit ID. The data segment is filled with fragment data. The fragment data frame is sent to other module chips in sequence. The fragment data frame sending interval must be greater than the single-chip data frame transmission processing and storage delay; The verification module is used to send a broadcast upgrade verification after the fragmented data of all module firmware is sent. The main chip sends a broadcast upgrade verification. The verification data segment is the verification word calculated by the verification word calculation module. The module chip receives the verification word and verifies the received and stored firmware data. If the verification is correct, the firmware of this module is upgraded, otherwise, the upgrade data is ignored; the main chip sends a broadcast upgrade exit message. After all module chips receive the message, they exit the upgrade mode and enter the normal working mode. The module chip resumes sending CAN data. If the module chip is successfully upgraded, it determines whether to restart according to the upgrade strategy.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by the processor, the broadcast upgrade method based on the CAN2.0B protocol as described in any one of claims 1-8 is implemented.