Search

CN-122018948-A - ECU software online upgrading method based on CAN bus retransmission

CN122018948ACN 122018948 ACN122018948 ACN 122018948ACN-122018948-A

Abstract

The invention provides an ECU software online upgrading method based on CAN bus retransmission, which is characterized in that a new user program is compiled and processed to generate a BIN file, upper computer software reads the BIN file to be programmed, and adds file identification header, file byte length and verification information to the BIN file, the number of blocks of the whole file, the number of bytes of the last block of data, the number of CAN message strips of the last block, the data verification value of the whole file and the verification value of each block of data are calculated according to the size 511 x 8 bytes of single block transmission, and the BIN file is packed into a start transmission command, a single block transmission end command and a block transmission end command after being subjected to data processing.

Inventors

  • CHENG SHI
  • ZHAO FUCHUAN
  • SUN LEI
  • LIU JIAXIANG
  • ZHANG WEI
  • Qiu fan
  • JU JUNMEI
  • WANG XINGXING
  • YAN DONGXIAO
  • WANG FENG

Assignees

  • 湖北三江航天红峰控制有限公司

Dates

Publication Date
20260512
Application Date
20251211

Claims (10)

  1. 1. The online upgrade method of the ECU software based on the CAN bus and capable of being retransmitted is characterized by comprising the following steps of: (1) Compiling the new user program to generate a BIN file, reading the BIN file to be programmed by the upper computer software, adding file identification header, file byte length and check information to the BIN file, calculating the number of blocks of the whole file according to 511 x 8 bytes of the single block transmission, the number of bytes of the last block of data, the number of CAN message strips of the last block, the data check value of the whole file and the check value of each block of data; (2) After packing the BIN file, the upper computer software enters a communication stage with the lower computer, the upper computer firstly sends a command for starting transmission, the lower computer analyzes information in the command for starting transmission after receiving the command to obtain the size of upgrade data, then the lower computer sends a response for starting transmission command, one frame of CAN message has eight bytes, a response state mark for starting transmission command is placed in a second byte, and the response for ending transmission command contains a prepared response state mark; (3) The lower computer checks the received first single block data, when the check value is consistent with the check value in the single block transmission ending command, a single block transmission ending command response is sent, a single block data check success mark of the single block transmission ending command is placed at a fifth byte of the response message, the nth single block data transmission is displayed on a check success interface after the response of the single block transmission ending command is received, the transmission of the next single block data is carried out, the block sequence number is increased by one before data packaging, the retransmission of the current block is carried out if the check is unsuccessful, so that the process is repeated until the last single block data transmission is ended, the upper computer sends a block ending command after the last single block data transmission is ended, and the block transmission ending command comprises the check value of the whole BIN file data; (4) After receiving the block transmission ending command, the lower computer checks the whole upgrade data cached in the memory (Flash, DDR, SDRAM and the like), if the check value is consistent with the check value in the received block transmission ending command, the lower computer checks successfully, sends a block transmission ending command response to the upper computer, and places a check success mark in a fifth byte; (5) After receiving the response of the block transmission ending command, the upper computer judges that the received verification success mark is a successful FLASH erasing command; (6) After receiving the FLASH erasing command, the lower computer erases the FLASH, records the erasing result, and then sends an erasing command response to the lower computer, wherein the command response contains the FLASH erasing result; (7) After receiving the FLASH erasing command response, the upper computer judges whether the erasing is successful, if so, the interface displays that the FLASH erasing is successful and then sends a FLASH writing command; (8) After receiving the writing command, the lower computer writes the upgrade data into the FLASH, then reads the upgrade data out for verification, and if the verification is successful, sends a writing command response to the upper computer, wherein the writing command response comprises a verification result of verifying the data written into the FLASH; (9) After the upper computer receives the response of the writing command, judging whether the verification result in the response is qualified or not, and printing and displaying the qualified interface to successfully upgrade and requesting to power off the product.
  2. 2. The method of claim 1, wherein in step (1), the open transmission command includes length information of the entire BIN file, the data area in the monolithic transmission command is the BIN file data content, the monolithic transmission end command includes a check value and a monolithic serial number of the monolithic data, and the monolithic transmission end command includes a check value of the entire BIN file data.
  3. 3. The online upgrade method of the ECU software based on the CAN bus retransmission as claimed in claim 1, wherein in the step (2), the PC, the CAN board card and the embedded control unit ECU (comprising a CAN interface) of the upper computer application program are communicated with the product by adopting the CAN bus interface, the CAN board card is connected with the PC by a special test cable, the CAN board card is directly inserted into the PC, and the CAN protocol between the upper computer and the lower computer is used for distributing and setting the ID of the CAN bus message based on the standard CAN protocol.
  4. 4. The online upgrade method of the ECU software based on the CAN bus retransmission as claimed in claim 1, wherein in the step (2), each step of operation in the upgrade flow of the upgrade data is set by adopting a one-to-one handshake mechanism, so that the reliability and timeliness of the whole upgrade process are improved.
  5. 5. The method for online upgrading of ECU software based on CAN bus retransmission as claimed in claim 1, wherein in step (2), the host computer analyzes and judges whether the transmission starting state is ready after receiving the response of the transmission starting command, if so, the host computer displays the ready state of the lower computer on the interface of the host computer, carries out single block (511) data transmission, sends 511 frames of CAN message data, and then sends a single block transmission ending command, wherein the single block transmission ending command comprises the check value and the block serial number information of the single block data.
  6. 6. The online upgrade method of the ECU software based on the CAN bus retransmission as claimed in claim 1, wherein in the step (3), the upgrade file of the BIN file is a binary file, the invention adopts a form of a BIN file format, and the CAN communication baud rate in the upgrade process is 800Kbps.
  7. 7. The online upgrade method of the ECU software based on the CAN bus retransmission of claim 1, wherein in the upgrade process of the upgrade data, the data is verified by adopting a 32-bit CRC verification mode according to the step (4), the data type of the whole upgrade data, the data written into FLASH and the like comprises single-block transmission data, and the accuracy of the data transmission is strictly ensured.
  8. 8. The online upgrade method of ECU software based on CAN bus retransmission as claimed in claim 1, wherein in step (4), the memory is a plug-in DDR, SDRAM or FLASH, the upgrade data is not directly written into the FLASH formal area in the upgrade process, but the received upgrade data is written into the temporary data buffer area, and after verification is successful, the upgrade data is written into the FLASH formal area.
  9. 9. The online upgrade method of the ECU software based on the CAN bus retransmission as claimed in claim 1, wherein in the step (4), the upgrade data is upgraded only by transmitting data through the CAN bus without disassembling the ECU control unit, and the online upgrade method is suitable for online upgrade of software of any ECU control unit with a CAN communication interface.
  10. 10. The online upgrade method of the ECU software based on the CAN bus retransmission as claimed in claim 1, wherein in the step (6), the reliability of the CAN bus transmission data is high, if errors occur in the upgrade data transmission process, the retransmission of the single block data with errors CAN be supported, and if the FLASH erasure and the writing operation fail, the retry operation CAN be performed, thereby greatly improving the upgrade efficiency and saving the upgrade time and cost.

Description

ECU software online upgrading method based on CAN bus retransmission Technical Field The invention relates to the technical field of embedded control, in particular to an ECU software online upgrading method based on CAN bus retransmission. Background Along with the continuous progress of technology, embedded equipment is widely applied in the modern society, and along with the continuous improvement of the performance of an embedded microprocessor, the function requirements of the embedded microprocessor software are increasingly complex and diversified, the frequency of software updating is higher, and a convenient method is necessary for software updating, so that the efficiency of software updating can be improved, and the cost of software updating is saved. The common software updating mode is to write the software through the JTAG port, the mode needs to disassemble the microcontroller from the assembly system, and the microcontroller does not need to be disassembled from the assembly system when uploading is carried out through the communication bus, so that the software updating cost is saved. The CAN bus communication technology is very mature and has high reliability. And the CAN bus is utilized to carry out on-line upgrade of the retransmitted ECU software, so that the operation is more reliable, convenient and efficient. Disclosure of Invention Aiming at the defects existing in the prior art, the invention aims to provide an ECU software online upgrading method based on CAN bus retransmission to solve the problems in the background art. The communication protocol between the upper computer software and the lower computer (ECU) software is a block transmission protocol based on a CAN bus. In order to achieve the aim, the invention is realized through the following technical scheme that the online upgrade method of the ECU software based on the CAN bus retransmission comprises the following steps: (1) Compiling the new user program to generate a BIN file, reading the BIN file to be programmed by the upper computer software, adding file identification header, file byte length and check information to the BIN file, calculating the number of blocks of the whole file according to 511 x 8 bytes of the single block transmission, the number of bytes of the last block of data, the number of CAN message strips of the last block, the data check value of the whole file and the check value of each block of data; (2) After packing the BIN file, the upper computer software enters a communication stage with the lower computer, the upper computer firstly sends a command for starting transmission, the lower computer analyzes information in the command for starting transmission after receiving the command to obtain the size of upgrade data, then the lower computer sends a response for starting transmission command, one frame of CAN message has eight bytes, a response state mark for starting transmission command is placed in a second byte, and the response for ending transmission command contains a prepared response state mark; (3) The lower computer checks the received first single block data, when the check value is consistent with the check value in the single block transmission ending command, a single block transmission ending command response is sent, a single block data check success mark of the single block transmission ending command is placed at a fifth byte of the response message, the nth single block data transmission is displayed on a check success interface after the response of the single block transmission ending command is received, the transmission of the next single block data is carried out, the block sequence number is increased by one before data packaging, the retransmission of the current block is carried out if the check is unsuccessful, so that the process is repeated until the last single block data transmission is ended, the upper computer sends a block ending command after the last single block data transmission is ended, and the block transmission ending command comprises the check value of the whole BIN file data; (4) After receiving the block transmission ending command, the lower computer checks the whole upgrade data cached in the memory (Flash, DDR, SDRAM and the like), if the check value is consistent with the check value in the received block transmission ending command, the lower computer checks successfully, sends a block transmission ending command response to the upper computer, and places a check success mark in a fifth byte; (5) After receiving the response of the block transmission ending command, the upper computer judges that the received verification success mark is a successful FLASH erasing command; (6) After receiving the FLASH erasing command, the lower computer erases the FLASH, records the erasing result, and then sends an erasing command response to the lower computer, wherein the command response contains the FLASH erasing result; (7) After receiving the FLASH