CAN-based software upgrade method, device, computer equipment and storage medium

The software update of train controllers is realized through the CAN network, solving the problems of low update efficiency and safety hazards in the existing technology, and realizing remote update of multi-node controllers, improving update efficiency and security.

CN113568629BActive Publication Date: 2024-11-19CRRC ZHUZHOU ELECTRIC LOCOMOTIVE RESEARCH INSTITUTE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010350275.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-04-28
Publication Date
2024-11-19
Estimated Expiration
2040-04-28

AI Technical Summary

Technical Problem

In the prior art, software updates of train controllers require disassembly of equipment, which are inefficient and have safety risks, and cannot achieve remote updates of multi-node controllers.

Method used

Through the CAN network, the upper computer sends update instructions to the controller, switches to the startup program, receives and writes update packages, and updates applications without the need for an emulator to update, realizing remote updates of applications for multi-node controllers.

Benefits of technology

It improves the efficiency and security of software updates, avoids the need to disassemble the equipment, and improves the maintenance efficiency of the product.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113568629B_ABST
    Figure CN113568629B_ABST
Patent Text Reader

Abstract

The present invention provides a software upgrade method, device, computer equipment and storage medium based on CAN, the method comprising receiving an update instruction from a host computer; in response to the update instruction, jumping the current running program from the application program to the startup program; in the startup program, receiving a file transfer request from the host computer; in response to the file transfer request, erasing the application program in the memory; receiving an update package from the host computer, and writing the update package into the memory. The host computer sends an update instruction to a controller via CAN, so that the controller stops the currently running application program and runs the startup program, so that after receiving the file transfer request from the host computer, the controller can erase the application program in the memory, and then after receiving the update package, the controller can absorb the update package into the memory, so that the application program is updated, and there is no need for an emulator to update the application program, which effectively improves the update efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software upgrading based on CAN communication, and in particular to a software upgrading method, device, computer equipment and storage medium based on CAN. Background Art

[0002] At present, multiple controllers of a train are networked through CAN (Controller Area Network), and the host computer is connected to the controller through the CAN network to achieve communication. During the debugging stage of the controller, since the application is not finalized, the application often needs to be updated and upgraded. Currently, the application needs to be updated after the controller is disassembled and updated using a simulator. However, this update method is inefficient and has safety risks. Summary of the invention

[0003] Based on this, it is necessary to provide a CAN-based software upgrade method, device, computer equipment and storage medium to address the above technical problems.

[0004] A software upgrade method based on CAN, comprising:

[0005] Receive update instructions from the host computer;

[0006] In response to the update instruction, the currently running program is jumped from the application program to the startup program;

[0007] In the startup program, receiving a file transfer request from the host computer;

[0008] In response to the file transfer request, erasing the application in the memory;

[0009] An update package from the host computer is received, and the update package is written into the memory, wherein the update package carries an updated application program.

[0010] In one embodiment, before the step of receiving the update instruction from the host computer, the method further includes:

[0011] Detecting whether an interception mode instruction from the host computer is received;

[0012] When the interception mode instruction of the host computer is detected, the current running program is maintained as the startup program.

[0013] In one embodiment, the step of detecting whether the interception mode instruction of the host computer is received includes:

[0014] After power-on, the startup program is run, and within a preset time after power-on, it is detected whether an interception mode instruction of the host computer is received.

[0015] In one embodiment, the step of receiving the update package from the host computer and writing the update package into the memory includes:

[0016] Receiving the update package and verification information from the host computer;

[0017] Calculating a check value of the update package according to a preset rule, and detecting whether the check value is consistent with the check information;

[0018] When the verification value is consistent with the verification information, the update package is written into the memory.

[0019] In one embodiment, before the step of receiving the update instruction from the host computer, the step further includes:

[0020] Receive a request instruction from the host computer, and send response information to the host computer in response to the request instruction.

[0021] A software upgrade method based on CAN, comprising:

[0022] Send update instructions to the controller;

[0023] sending a file transfer request to the controller;

[0024] An update package is sent to the controller, wherein the update package carries an updated application program.

[0025] In one embodiment, before the step of sending the update instruction to the controller, the method further includes:

[0026] An intercept mode instruction is sent to the controller.

[0027] In one embodiment, the step of sending the interception mode instruction to the controller includes:

[0028] Within a preset time after the controller is powered on, an interception mode instruction is sent to the controller.

[0029] A software upgrade method based on CAN, characterized by comprising:

[0030] The host computer sends an update command to the controller;

[0031] The controller jumps the currently running program from the application program to the startup program in response to the update instruction;

[0032] The host computer sends a file transfer request to the controller;

[0033] The controller receives a file transfer request from the host computer in the startup program, and erases the application program in the memory in response to the file transfer request;

[0034] The host computer sends an update package to the controller, wherein the update package carries the updated application program;

[0035] The controller receives the update package from the host computer, and writes the update package into the memory.

[0036] In one embodiment, before the step of the host computer sending an update instruction to the controller, the step further includes:

[0037] The host computer sends an interception mode instruction to the controller;

[0038] The controller maintains the current running program as the startup program when detecting the interception mode instruction of the host computer within a preset time after power-on.

[0039] A software upgrade device based on CAN, comprising:

[0040] An update instruction receiving module is used to receive update instructions from a host computer;

[0041] A program jump module, for jumping the currently running program from the application program to the startup program in response to the update instruction;

[0042] A file transfer request receiving module, used for receiving a file transfer request from the host computer in the startup program;

[0043] A program erasing module, configured to erase the application program in the memory in response to the file transfer request;

[0044] An update package writing module is used to receive the update package of the host computer and write the update package into the memory, wherein the update package carries the updated application program.

[0045] A software upgrade device based on CAN, comprising:

[0046] An update instruction sending module, used for sending an update instruction to the controller;

[0047] A file transfer request sending module, used to send a file transfer request to the controller;

[0048] The update package sending module is used to send an update package to the controller, wherein the update package carries an updated application program.

[0049] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and wherein the processor implements the following steps when executing the computer program:

[0050] Receive update instructions from the host computer;

[0051] In response to the update instruction, the currently running program is jumped from the application program to the startup program;

[0052] In the startup program, receiving a file transfer request from the host computer;

[0053] In response to the file transfer request, erasing the application in the memory;

[0054] An update package from the host computer is received, and the update package is written into the memory, wherein the update package carries an updated application program.

[0055] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and wherein the processor implements the following steps when executing the computer program:

[0056] Send update instructions to the controller;

[0057] sending a file transfer request to the controller;

[0058] An update package is sent to the controller, wherein the update package carries an updated application program.

[0059] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:

[0060] Receive update instructions from the host computer;

[0061] In response to the update instruction, the currently running program is jumped from the application program to the startup program;

[0062] In the startup program, receiving a file transfer request from the host computer;

[0063] In response to the file transfer request, erasing the application in the memory;

[0064] An update package from the host computer is received, and the update package is written into the memory, wherein the update package carries an updated application program.

[0065] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:

[0066] Send update instructions to the controller;

[0067] sending a file transfer request to the controller;

[0068] An update package is sent to the controller, wherein the update package carries an updated application program.

[0069] In the above-mentioned CAN-based software upgrade method, device, computer equipment and storage medium, the host computer sends an update instruction to the controller via CAN, so that the controller stops the currently running application and runs the startup program, so that after receiving the file transfer request from the host computer, the controller can erase the application in the memory, and then after receiving the update package, it can absorb the update package into the memory, so that the application is updated, and there is no need for an emulator to update the application, which effectively improves the update efficiency and security. Remote update of the application of multi-node controllers is realized, without disassembling the chassis to connect the emulator to refresh the underlying BOOT program, which improves the maintenance efficiency of the product. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] Figure 1A 1 is a flow chart of a CAN-based software upgrade method in an embodiment;

[0071] Figure 1B is a flowchart of a CAN-based software upgrade method in another embodiment;

[0072] Figure 2 1 is a flow chart of a CAN-based software upgrade method in yet another embodiment;

[0073] Figure 3 A flowchart of a CAN-based software upgrade method in another embodiment;

[0074] Figure 4 is a structural block diagram of a CAN-based software upgrade device in one embodiment;

[0075] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0076] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0077] In one embodiment, Figure 1A As shown, a CAN-based software upgrade method is provided. The CAN-based software upgrade method in this embodiment is applicable to a controller, and includes:

[0078] Step 110, receiving an update instruction from a host computer.

[0079] Specifically, the update instruction is sent from the host computer to the controller via CAN, and the controller receives the update instruction from the host computer via CAN. The update instruction is used to make the controller switch the currently running application to the startup program.

[0080] In this embodiment, a maximum of 32 chassis are arranged in one carriage, and a controller is set in each chassis. The 32 controllers are equivalent to 32 nodes in the CAN communication network, and the host computer is connected to the 32 controllers through CAN, so that the 32 controllers can communicate with the host computer.

[0081] Step 120: In response to the update instruction, the currently running program is jumped from the application program to the startup program.

[0082] Specifically, the boot program is also called a BOOT program. The boot program is a low-level program, while the application program is a system-level or application-level program. Generally speaking, during the operation of the controller, the program running on it is called an application program. In this step, when the controller receives an update instruction, the controller responds to the update instruction and switches the currently running program from the application program to the boot program, that is, stops the currently running application program and runs the boot program.

[0083] Step 130: In the startup program, a file transfer request from the host computer is received.

[0084] Specifically, the file transfer request is sent by the host computer, and the file transfer request carries the file information of the update package, which includes the data volume of the update package and the serial number of the updated application. The data volume records the file size of the updated application, and the serial number of the updated application corresponds to one of the CPUs (central processing units) of the controller, such as CPU1 or CPU2.

[0085] In this step, since the currently running program is a startup program, under this program, it is possible to receive a file transfer request from a host computer and respond to the file transfer request from the host computer.

[0086] Step 140: In response to the file transfer request, erase the application in the memory.

[0087] Specifically, when the controller receives a file transfer request, it indicates that there is an application that needs to be updated. Therefore, in this step, the controller responds to the file transfer request and erases the application in the memory. It should be understood that since the application is stopped, the application can be erased in this step. Since the application in the memory is erased, the updated application can be written. In addition, it should be understood that the application and the startup program can be stored in the same memory. For example, the application and the startup program are both stored in FLASH (flash memory), but the application and the startup program are stored in different addresses in the memory. Therefore, the application in the memory will be deleted without affecting the startup program.

[0088] Step 150, receiving an update package from the host computer, and writing the update package into the memory, wherein the update package carries an updated application program.

[0089] Specifically, the data carried in the update package is the application to be updated or the updated application. In this step, since the original application stored in the memory is erased, after receiving the update package from the host computer, the controller can write the application carried in the update package to the erased address in the memory, so that the application is updated.

[0090] In the above embodiment, the host computer sends an update instruction to the controller via CAN, so that the controller stops the currently running application and runs the startup program, so that after receiving the file transfer request from the host computer, the controller can erase the application in the memory, and then after receiving the update package, it can absorb the update package into the memory, so that the application is updated, and the emulator is not required to update the application, which effectively improves the update efficiency and security. The remote update of the application of the multi-node controller is realized, and there is no need to disassemble the chassis to connect the emulator to refresh the underlying BOOT program, which improves the maintenance efficiency of the product.

[0091] In order to efficiently update the application when an exception or error occurs in the application, in one embodiment, Figure 1B As shown, before the step of receiving the update instruction of the host computer, the step also includes:

[0092] Step 101, detecting whether an interception mode instruction from the host computer is received.

[0093] Step 102, when the interception mode instruction of the host computer is detected, the current running program is maintained as the startup program.

[0094] It is worth mentioning that when there is an abnormality in the application on the controller, the controller cannot jump from the currently running application to the startup program. Specifically, in the absence of an interception mode, the controller will first run the startup program each time it is powered on. The startup program detects whether there is an application in the controller. If there is an application, it will jump to the application and start executing the application. When the application is running normally, if it receives a program update instruction, it will jump to the startup program and update the application. If the application is abnormal, it may cause the application to be unable to jump to the startup program, and the application cannot be updated. At this time, the chassis needs to be disassembled and the application needs to be erased with an emulator before the application can be updated normally. This undoubtedly takes a lot of time and is inefficient.

[0095] In this embodiment, upon receiving the interception mode instruction from the host computer, the controller will continue the currently running startup program and will not jump to the application program. Specifically, the host computer sends an interception mode instruction to the controller, so that the controller works in the interception mode, that is, the currently running program is maintained as the startup program, so that the program currently running by the controller stays in the startup program, thereby avoiding the controller from jumping to the application program by default. Since the controller stays in the startup program in the interception mode without entering the application program, even if an exception or error occurs in the application program, the application program in the memory can still be erased and the application program can be updated.

[0096] In the above embodiment, not only the remote update of the application program of the multi-node controller is realized, but also when the wrong application program is updated, there is no need to disassemble the chassis to connect the simulator to refresh the underlying BOOT program, thereby improving the maintenance efficiency of the product.

[0097] In order to enable the controller to enter the interception mode in time when the application is updated, in one embodiment, step 101 is to run the startup program after power-on, and detect whether the interception mode instruction of the host computer is received within a preset time after power-on.

[0098] Step 102 is: when the interception mode instruction of the host computer is detected within a preset time after power-on, maintaining the current running program as the startup program.

[0099] It should be understood that when the interception mode instruction is not received, the controller will jump from the startup program to the application program after the preset time of power-on. In this way, when the application program is abnormal or erroneous, it will not be able to jump to the startup program for updating. Therefore, in this embodiment, when the application program needs to be updated, before the controller is powered on, the host computer first starts the interception mode, and when the controller is powered on, the interception mode instruction is sent to the controller. Since the controller will continue to run the startup program within the preset time after power-on, and will not jump to the application program within the preset time, the controller will continue to run the startup program after receiving the interception mode instruction within the preset time. After the preset time, it will still stay in the startup program and will not jump to the application program, thereby achieving that even if the application program is abnormal or erroneous, the application program in the memory can still be erased and the application program can be updated. It should be understood that in this embodiment, by configuring the controller to run the startup program within the preset time after power-on, by reserving the preset time, the controller can receive the interception mode instruction in time before jumping to the application program, thereby effectively avoiding the controller from running the application program when the application program needs to be updated.

[0100] In one embodiment, the step of receiving the update package from the host computer and writing the update package into the memory includes: receiving the update package and verification information from the host computer; calculating a verification value of the update package according to a preset rule, and detecting whether the verification value is consistent with the verification information; when the verification value is consistent with the verification information, writing the update package into the memory.

[0101] In this embodiment, by comparing the verification value and the verification information, it is detected whether the update package sent by the upper computer is consistent with the update package received by the controller, thereby verifying whether the update package received by the controller is incorrect. When the verified update package is correct, the update package is written into the memory to implement the update of the application.

[0102] In this embodiment, the verification information of the host computer is generated according to the update package, for example, the host computer calculates the verification information of the update package according to the preset rules. In one embodiment, the preset rule is to accumulate the values ​​of each byte in the update package, for example, the host computer accumulates the values ​​of each byte in the update package to obtain the verification information, the controller accumulates the values ​​of each byte of the received update package to obtain the verification value, and detects whether the verification value and the value of the verification information are consistent. When the two are consistent, it indicates that the update package received by the controller is complete and error-free.

[0103] It should be understood that the application includes multiple data packets, each of which is an update packet, and each data packet includes 512 bytes. It should be understood that the last data packet among the multiple data packets may be less than 512 bytes. One byte in each data packet is the packet sequence number, which needs to be used to record the sequence number of the currently transmitted data packet so that the controller can confirm which data packet the currently received data packet is.

[0104] In one embodiment, the step of writing the update package into the memory also includes: receiving the update package from the host computer; parsing the update package to obtain a package sequence number, and writing the update package into the memory in sequence according to the package sequence number. For example, detecting whether the update package is lost according to the package sequence number, and when it is detected that the update package is lost, sending a retransmission request to the host computer, and the retransmission request carries the package sequence number of the lost update package. In this way, the controller can write the update package into the memory in sequence according to the package sequence number. In addition, it can also detect whether the update package is lost. For example, when there is a package sequence number between two package sequence numbers that has not been received, indicating that the update package is lost, the controller requests the host computer to retransmit the lost update package, so that the application can be downloaded completely by the controller.

[0105] In one embodiment, the step of writing the update package into the memory includes: receiving the update package and verification information from the host computer; calculating the checksum of all the received update packages, and detecting whether the checksum value is consistent with the verification information; when the checksum value is consistent with the verification information, writing the update package into the memory.

[0106] In this embodiment, the verification information is the value obtained by the upper computer adding up the bytes of all update packets, and the checksum is the value obtained by the controller adding up the bytes of all received update packets. By comparing the two, after all update packets are sent, all update packets are verified to detect whether the controller has received all update packets completely and without errors.

[0107] In one embodiment, before the step of receiving the update instruction from the host computer, the step also includes: receiving a request instruction from the host computer, and sending response information to the host computer in response to the request instruction.

[0108] In this embodiment, the host computer adopts a response mode for updating the application program of the controller. In this embodiment, the host computer sends a request instruction to the controller, and the request instruction is used to detect whether the communication between the controller and the host computer is normal. When the host computer receives the response information sent by the controller in response to the request instruction, it indicates that the controller can respond in time, the communication between the two is stable, and the application program can be updated.

[0109] For example, the host computer sends a request command, and then sends the next frame command after receiving the response from the controller. If no response is received within 1s, the host computer sends the command again after an interval of 1s. If no response is received within 1s, the host computer sends the command again after an interval of 2s. If no response is received within 1s, the host computer reports an error.

[0110] In one embodiment, a CAN-based software upgrade method is provided. The CAN-based software upgrade method in this embodiment is applicable to a host computer, such as Figure 2 As shown, it includes:

[0111] Step 210: Send an update instruction to the controller.

[0112] In this embodiment, the host computer sends an update instruction to the controller via CAN. The update instruction is used to make the controller switch the currently running application to the startup program.

[0113] In this embodiment, a maximum of 32 chassis are arranged in one carriage, and a controller is set in each chassis. The 32 controllers are equivalent to 32 nodes in the CAN communication network, and the host computer is connected to the 32 controllers through CAN, so that the 32 controllers can communicate with the host computer.

[0114] Step 220: When the controller jumps the currently running program from the application program to the startup program, a file transfer request is sent to the controller.

[0115] In this embodiment, when the controller receives the update instruction, it will respond to the update instruction and jump the current running program from the application to the startup program. The controller runs the startup program at this time. At this time, the host computer sends a file transfer request to the controller. The file transfer request carries the file information of the update package, which includes the data volume of the update package and the serial number of the updated application. After receiving the file transfer request, the controller erases the application in the memory of the controller.

[0116] Step 230: Send an update package to the controller, wherein the update package carries the updated application program.

[0117] In this embodiment, after the controller erases the application in its memory, an update package is sent to the controller, so that the controller writes the update package carrying the updated application into the memory, so that the application of the controller is updated.

[0118] In order to efficiently update the application when an exception or error occurs in the application, in one embodiment, before the step of sending the update instruction to the controller, the step also includes: sending an interception mode instruction to the controller.

[0119] It is worth mentioning that when an application on the controller is abnormal, the controller cannot jump from the currently running application to the startup program. In this embodiment, the interception mode instruction is used to make the controller maintain the currently running program in the startup program, so that when the controller receives the interception mode instruction, it can stay in the startup program instead of jumping to the application. Since the controller stays in the startup program in the interception mode without entering the application, even if an abnormality or error occurs in the application, the application in the memory can still be erased and the application can be updated.

[0120] In one embodiment, the step of sending the interception mode instruction to the controller includes: sending the interception mode instruction to the controller within a preset time after the controller is powered on.

[0121] It should be understood that when the interception mode instruction is not received, the controller will jump from the startup program to the application program after the preset time of power-on. In this way, when the application program is abnormal or erroneous, it will not be able to jump to the startup program for updating. Therefore, in this embodiment, when the application program needs to be updated, before the controller is powered on, the host computer first starts the interception mode, and when the controller is powered on, the interception mode instruction is sent to the controller. Since the controller will continue to run the startup program within the preset time after power-on, and will not jump to the application program within the preset time, the controller will continue to run the startup program after receiving the interception mode instruction within the preset time. After the preset time, it will still stay in the startup program and will not jump to the application program, thereby achieving that even if the application program is abnormal or erroneous, the application program in the memory can still be erased and the application program can be updated. It should be understood that in this embodiment, by configuring the controller to run the startup program within the preset time after power-on, by reserving the preset time, the controller can receive the interception mode instruction in time before jumping to the application program, thereby effectively avoiding the controller from running the application program when the application program needs to be updated.

[0122] In one embodiment, step 230 includes sending an update package and verification information to the controller. In this embodiment, the verification information of the host computer is generated according to the update package. For example, the host computer calculates the verification information of the update package according to a preset rule. In one embodiment, the preset rule is to accumulate the value of each byte in the update package. For example, the host computer accumulates the value of each byte in the update package to obtain the verification information. In this way, after the controller obtains the verification information, it can verify the received update package to detect whether the update package received by the controller is complete and error-free.

[0123] It should be understood that although Figure 1A-1BThe steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. For example, Figure 1B The steps can be Figure 1A Before any step in Figure 1A After executing any step in Figure 1B The steps can be Figure 1A Before any step in Figure 1A After any step in . And, Figure 1A-1B At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0124] In one embodiment, Figure 3 As shown, a CAN-based software upgrade method is provided, comprising:

[0125] Step 310, the host computer sends an update instruction to the controller;

[0126] Step 320, the controller jumps the currently running program from the application program to the startup program in response to the update instruction;

[0127] Step 330, the host computer sends a file transfer request to the controller;

[0128] Step 340, the controller receives a file transfer request from the host computer in the startup program, and erases the application in the memory in response to the file transfer request;

[0129] Step 350, the host computer sends an update package to the controller, wherein the update package carries the updated application program;

[0130] Step 360: The controller receives the update package from the host computer and writes the update package into the memory.

[0131] In the above embodiment, the host computer sends an update instruction to the controller via CAN, so that the controller stops the currently running application and runs the startup program, so that after receiving the file transfer request from the host computer, the controller can erase the application in the memory, and then after receiving the update package, it can absorb the update package into the memory, so that the application is updated, and the emulator is not required to update the application, which effectively improves the update efficiency and security. The remote update of the application of the multi-node controller is realized, and there is no need to disassemble the chassis to connect the emulator to refresh the underlying BOOT program, which improves the maintenance efficiency of the product.

[0132] In one embodiment, before the step of the host computer sending an update instruction to the controller, the step also includes: the host computer sends an interception mode instruction to the controller; and the controller maintains the current running program as the startup program when detecting the interception mode instruction from the host computer within a preset time after power-on.

[0133] In this embodiment, if there is an exception or error in the application on the controller, it is impossible to jump from the application to the startup program. Therefore, the controller will run the startup program within the preset time after power-on. During this period, the host computer sends an intercept mode instruction to the controller so that the controller can stay in the startup program and update the application.

[0134] The following is a specific embodiment:

[0135] This embodiment implements online software upgrade of a dual-core MCU (Microcontroller Unit) in a maglev train networking multi-controller system based on CAN communication.

[0136] A maximum of 32 chassis are arranged in a carriage, and a controller is set in each chassis. The 32 controllers are equivalent to 32 nodes in the CAN communication network. The host computer interacts with these 32 nodes for data, so it is necessary to assign IDs (Identity documents) to the 32 nodes respectively in order to implement program updates for a single node and all nodes. The length of the CAN communication standard frame ID is 11 bits, and its lower 6 bits (bit0~bit5) identify the addresses of the 32 nodes, that is, the lower 6 bits are the device identification bits, which are used to identify the addresses of the nodes, and the addresses of the nodes are different. The remaining 5 bits of the communication standard frame are used to distinguish functions. The structure of the CAN communication frame is shown in Table 1:

[0137] Table 1 CAN communication frame ID allocation

[0138]

[0139] In Table 1, single-point program download means that the node receiving the frame updates the application, while all-node program download means that all nodes receiving the frame update the application. Intercept mode single-point program download means that the node receiving the frame enters the intercept mode, maintains the currently running startup program, and does not jump to the application; intercept mode all-node program download means that all nodes receiving the frame enter the intercept mode, maintain the currently running startup program, and do not jump to the application.

[0140] The host computer adopts the response mode to the controller update program, that is, the host computer sends a request command, and sends the next frame command after receiving the response from the controller. If no response is received within 1s, the host computer will send the command again after an interval of 1s. If no response is received within 1s, the host computer will send the command again after an interval of 2s. If no response is received within 1s, the host computer will report an error. The specific steps for program update are as follows:

[0141] 1. Download enable: The host computer informs the controller that a program update is about to be performed, and the controller execution program jumps from the application program to the BOOT program, preparing for the program update.

[0142] 2. File transfer request: The host computer sends the program file size and the download program number (CPU1 or CPU2) to the device. After receiving the command, the device erases the application in the corresponding Flash.

[0143] 3. File download: The host computer sends the contents of the program file to the device in packets. It is necessary to send a full packet of 512 bytes (excluding the last 512 bytes). When sending, the host computer uses a one-byte packet number (ranging from 0 to 255, and starting from 0 after exceeding 255) to identify which packet is currently being transmitted. The device needs to verify the packet number.

[0144] 4. Checksum: After reading the program file content, the host computer calculates the checksum and sends it to the device. The device confirms whether the program content transmitted by the host computer is correct based on the received checksum. Checksum calculation method: All program contents are accumulated and summed according to bytes, and the final result is an unsigned 32-bit value.

[0145] In the absence of interception mode, the BOOT program is run each time the controller is powered on. The BOOT program detects whether there is an application in the controller. If there is an application, it jumps to the application and starts executing the application. When the application is running normally, if it receives a program update instruction, it jumps to the BOOT program to update the application. If the application is abnormal, it may cause the application to be unable to jump to the BOOT program, and the application cannot be updated. In this case, you need to disassemble the chassis and use an emulator to erase the application before you can update the application normally.

[0146] In order to solve this problem, an interception mode is added in this embodiment. Before the controller is powered on, the upper computer first starts the interception mode and sends an interception mode instruction to the controller. After the controller is powered on, it will stay in the BOOT program for 1 second. During this time period, if an interception mode instruction is received, the controller will stay in the BOOT program to complete the update of the application.

[0147] In one embodiment, Figure 4 As shown, a CAN-based software upgrade device is provided, which is applied to a controller communicating with a host computer, including:

[0148] An update instruction receiving module 410 is used to receive an update instruction from a host computer;

[0149] A program jump module 420, for jumping the currently running program from the application program to the startup program in response to the update instruction;

[0150] A file transfer request receiving module 430, used to receive a file transfer request from the host computer in the startup program;

[0151] A program erasing module 440, configured to erase the application program in the memory in response to the file transfer request;

[0152] The update package writing module 450 is used to receive the update package from the host computer and write the update package into the memory, wherein the update package carries the updated application program.

[0153] In one embodiment, the CAN-based software upgrade device further includes:

[0154] An interception mode instruction detection module, used to detect whether an interception mode instruction of the host computer is received;

[0155] The current program maintaining module is used to maintain the current running program as the startup program when the interception mode instruction of the host computer is detected.

[0156] In one embodiment, the interception mode instruction detection module is used to run the startup program after power-on, and detect whether the interception mode instruction of the host computer is received within a preset time after power-on.

[0157] In one embodiment, the update package writing module includes:

[0158] A verification information receiving unit, used to receive the update package and verification information of the host computer;

[0159] A verification information detection unit, configured to calculate a verification value of the update package according to a preset rule, and detect whether the verification value is consistent with the verification information;

[0160] An update package writing unit is used to write the update package into the memory when the verification value is consistent with the verification information.

[0161] In one embodiment, the CAN-based software upgrade device further includes:

[0162] The response module is used to receive the request instruction of the host computer, and send response information to the host computer in response to the request instruction.

[0163] In one embodiment, a CAN-based software upgrade device is provided, which is applied to a host computer communicating with a controller, including:

[0164] An update instruction sending module, used for sending an update instruction to the controller;

[0165] A file transfer request sending module, used to send a file transfer request to the controller;

[0166] The update package sending module is used to send an update package to the controller, wherein the update package carries an updated application program.

[0167] In one embodiment, the CAN-based software upgrade device further includes an interception mode instruction sending module, which is used to send an interception mode instruction to the controller.

[0168] In one embodiment, the interception mode instruction sending module is used to send an interception mode instruction to the controller within a preset time after the controller is powered on.

[0169] For the specific definition of the CAN-based software upgrade device, please refer to the definition of the CAN-based software upgrade method above, which will not be repeated here. Each module in the above-mentioned CAN-based software upgrade device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0170] In one embodiment, a computer device is provided, which is a controller on a maglev train. Its internal structure diagram can be as follows: Figure 5As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with the host computer through a CAN connection. When the computer program is executed by the processor, a CAN-based software upgrade method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0171] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0172] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0173] Receive update instructions from the host computer;

[0174] In response to the update instruction, the currently running program is jumped from the application program to the startup program;

[0175] In the startup program, receiving a file transfer request from the host computer;

[0176] In response to the file transfer request, erasing the application in the memory;

[0177] An update package from the host computer is received, and the update package is written into the memory, wherein the update package carries an updated application program.

[0178] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0179] Detecting whether an interception mode instruction from the host computer is received;

[0180] When the interception mode instruction of the host computer is detected, the current running program is maintained as the startup program.

[0181] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0182] After power-on, the startup program is run, and within a preset time after power-on, it is detected whether an interception mode instruction of the host computer is received.

[0183] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0184] Receiving the update package and verification information from the host computer;

[0185] Calculating a check value of the update package according to a preset rule, and detecting whether the check value is consistent with the check information;

[0186] When the verification value is consistent with the verification information, the update package is written into the memory.

[0187] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0188] Receive a request instruction from the host computer, and send response information to the host computer in response to the request instruction.

[0189] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0190] Send update instructions to the controller;

[0191] sending a file transfer request to the controller;

[0192] An update package is sent to the controller, wherein the update package carries an updated application program.

[0193] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0194] An intercept mode instruction is sent to the controller.

[0195] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0196] Within a preset time after the controller is powered on, an interception mode instruction is sent to the controller.

[0197] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0198] Receive update instructions from the host computer;

[0199] In response to the update instruction, the currently running program is jumped from the application program to the startup program;

[0200] In the startup program, receiving a file transfer request from the host computer;

[0201] In response to the file transfer request, erasing the application in the memory;

[0202] An update package from the host computer is received, and the update package is written into the memory, wherein the update package carries an updated application program.

[0203] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0204] Detecting whether an interception mode instruction from the host computer is received;

[0205] When the interception mode instruction of the host computer is detected, the current running program is maintained as the startup program.

[0206] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0207] After power-on, the startup program is run, and within a preset time after power-on, it is detected whether an interception mode instruction of the host computer is received.

[0208] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0209] Receiving the update package and verification information from the host computer;

[0210] Calculating a check value of the update package according to a preset rule, and detecting whether the check value is consistent with the check information;

[0211] When the verification value is consistent with the verification information, the update package is written into the memory.

[0212] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0213] Receive a request instruction from the host computer, and send response information to the host computer in response to the request instruction.

[0214] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0215] Send update instructions to the controller;

[0216] sending a file transfer request to the controller;

[0217] An update package is sent to the controller, wherein the update package carries an updated application program.

[0218] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0219] An intercept mode instruction is sent to the controller.

[0220] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0221] Within a preset time after the controller is powered on, an interception mode instruction is sent to the controller.

[0222] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing related hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0223] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0224] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A software upgrade method based on CAN, characterized in that: include: Receive update instructions from the host computer; In response to the update instruction, the currently running program is jumped from the application program to the startup program; In the startup program, receiving a file transfer request from the host computer; In response to the file transfer request, erasing the application in the memory; receiving an update package from the host computer, and writing the update package into the memory, wherein the update package carries the updated application program; Before the step of receiving the update instruction from the host computer, the method further includes: Detecting whether an interception mode instruction from the host computer is received; When the interception mode instruction of the host computer is detected, maintaining the current running program as the startup program; The step of detecting whether the interception mode instruction of the host computer is received comprises: After power-on, the startup program is run, and within a preset time after power-on, it is detected whether an interception mode instruction of the host computer is received.

2. The method according to claim 1, characterized in that The step of receiving the update package from the host computer and writing the update package into the memory comprises: Receiving the update package and verification information from the host computer; Calculating a check value of the update package according to a preset rule, and detecting whether the check value is consistent with the check information; When the verification value is consistent with the verification information, the update package is written into the memory.

3. The method according to claim 1 or 2, characterized in that: The step of receiving the update instruction of the host computer also includes: Receive a request instruction from the host computer, and send response information to the host computer in response to the request instruction.

4. A software upgrade method based on CAN, characterized in that: include: Send update instructions to the controller; sending a file transfer request to the controller; Sending an update package to the controller, wherein the update package carries an updated application program; Before the step of sending the update instruction to the controller, the method further includes: Sending an interception mode instruction to the controller includes: sending an interception mode instruction to the controller within a preset time after the controller is powered on.

5. A software upgrade method based on CAN, characterized in that: include: The host computer sends an update command to the controller; The controller jumps the currently running program from the application program to the startup program in response to the update instruction; The host computer sends a file transfer request to the controller; The controller receives a file transfer request from the host computer in the startup program, and erases the application program in the memory in response to the file transfer request; The host computer sends an update package to the controller, wherein the update package carries the updated application program; The controller receives the update package from the host computer and writes the update package into the memory; Before the step of the host computer sending an update instruction to the controller, the method further includes the following steps: The host computer sends an interception mode instruction to the controller; The controller maintains the current running program as the startup program when detecting the interception mode instruction of the host computer within a preset time after power-on; wherein the step of detecting the interception model instruction includes: after power-on, running the startup program, and detecting whether the interception mode instruction of the host computer is received within a preset time after power-on.

6. A CAN-based software upgrade device, characterized in that: include: An update instruction receiving module is used to receive update instructions from a host computer; A program jump module, for jumping the currently running program from the application program to the startup program in response to the update instruction; A file transfer request receiving module, used for receiving a file transfer request from the host computer in the startup program; A program erasing module, configured to erase the application program in the memory in response to the file transfer request; An update package writing module, used for receiving an update package from the host computer and writing the update package into the memory, wherein the update package carries the updated application program; The interception mode instruction detection module is used to detect whether the interception mode instruction of the host computer is received, including: after power-on, running the startup program, and detecting whether the interception mode instruction of the host computer is received within a preset time after power-on; The current program maintaining module is used to maintain the current running program as the startup program when the interception mode instruction of the host computer is detected.

7. A CAN-based software upgrade device, characterized in that: include: An update instruction sending module, used for sending an update instruction to the controller; A file transfer request sending module, used to send a file transfer request to the controller; An update package sending module, used to send an update package to the controller, wherein the update package carries an updated application program; The interception mode instruction sending module is used to send the interception mode instruction to the controller, including: sending the interception mode instruction to the controller within a preset time after the controller is powered on.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 are implemented.