Program upgrade system, method, device and storage medium based on NB-IoT module

Through the program upgrade system of the NB-IoT module, combined with NB-IoT and the original bus protocol, low-power and high-accuracy remote motor controller program upgrades are achieved, solving the problems of complexity and high cost of traditional methods and ensuring Data stability and accuracy.

CN111897560BActive Publication Date: 2024-10-15HANGZHOU ZHOUJU ELECTRONICS TECHNOLOGICAL
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010880631.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-27
Publication Date
2024-10-15
Estimated Expiration
2040-08-27

AI Technical Summary

Technical Problem

Traditional motor controller program upgrade methods are complex and costly to operate on site, have low data accuracy, and consume large amounts of power, making it impossible to achieve efficient remote program upgrades.

Method used

Using a program upgrade system based on NB-IoT modules, remote program upgrades are performed through low-power consumption and wide-coverage NB-IoT connections. Combined with the BootLoader of the original bus protocol, on-site and remote two-way upgrades are achieved, and data is directly uploaded to the cloud to ensure accuracy and stability.

Benefits of technology

It achieves low-power, accurate and stable remote program upgrade, expands the operating range, reduces equipment costs, ensures the accuracy and stability of program programming data, and monitors and corrects the upgrade status in real time through an error handling mechanism.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111897560B_ABST
    Figure CN111897560B_ABST
Patent Text Reader

Abstract

The present invention relates to a program upgrade system based on NB-IoT module, including an MCU processor, the MCU processor is connected to the NB module, the NB module is connected to the IoT platform through the base station and the core network, and the IoT platform is connected to the remote server; the MCU processor is connected to the CAN transceiver, the CAN transceiver is connected to the CAN port, the CAN port is connected to the PC through the USB to CAN module and the USB cable, and the PC is also connected to the MCU processor through the USB cable and the USB to serial port module. The present invention uses the low-power and wide-coverage NB-IoT for remote program upgrades. The NB-IoT data is directly uploaded to the cloud, which is very accurate, and can be compatible with the BootLoader using the original bus protocol to realize program download, retaining its use while expanding the scope of operation, and realizing both on-site and remote program upgrades.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of embedded systems, and in particular relates to a program upgrade system, method, device and storage medium based on an NB-IoT module. Background Art

[0002] To upgrade the traditional motor controller program, in order to avoid connecting to the hardware to transmit instructions to re-burn the program, the program can be downloaded through the Bootloader of CAN or other serial port protocols, or remotely upgraded through Bluetooth or wife wireless network.

[0003] However, the above method is very complicated when connecting the bus for manual on-site operation, and the data collected by technologies such as Wi-Fi and Bluetooth are very inaccurate, consume a lot of power, and the overall equipment cost is high. Summary of the invention

[0004] In order to solve the above problems, the present invention proposes a program upgrade system, method, device and storage medium based on the NB-IoT module, selects the low-power and wide-coverage NB-IoT for remote program upgrade, and uploads the data directly to the cloud, which is very accurate and compatible with the BootLoader that uses the original bus protocol to realize program download. While retaining its use, it expands the operating range and realizes both on-site and remote program upgrades.

[0005] The technical solution of the present invention is as follows:

[0006] The program upgrade system based on the NB-IoT module includes an MCU processor, the MCU processor is connected to the NB module, the NB module is connected to the IoT platform through the base station and the core network, and the IoT platform is communicatively connected to the remote server; the MCU processor is connected to the CAN transceiver, the CAN transceiver is connected to the CAN port, the CAN port is connected to the PC through the USB to CAN module and the USB cable, and the PC is also connected to the MCU processor through the USB cable and the USB to serial port module.

[0007] Preferably, the CAN transceiver is connected to the CAN pin of the MCU via CAN_RX and CAN_TX, the CAN transceiver is connected to the CAN port via CAN_H and CAN_L, and the USB to serial port module is connected to the UART1 pin of the MCU processor via UART_RX and UART_TX.

[0008] Preferably, the NB module includes a NB-IoT module, a filter antenna circuit, and a SIM card holder. The NB-IoT module is connected to the filter antenna circuit and the SIM card holder, respectively, and the NB-IoT module is connected to the UART2 pin of the MCU processor via UART.

[0009] Preferably, the MCU processor includes a flash storage area, and the flash storage area includes a Boot loader storage area, an application APP storage area, and a marking area from top to bottom.

[0010] Preferably, the Boot loader storage area includes a Bootloader vector table and a Bootloader program, the application APP storage area includes an App interrupt vector table and an APP program relocated at the beginning of the main function, and the marking area includes an APP verification code and an IAP verification code.

[0011] The present invention also provides a program upgrade method based on an NB-IoT module and a program upgrade system based on an NB-IoT module, comprising the following steps:

[0012] S1: The MCU processor is powered on and reset, and the program entry address is obtained from the reset vector of the Bootloader vector table. The flash, CAN, UART and system timer are initialized, and the interrupt is set. The system timer starts timing; the Bootloader protocol is initialized, and the AT command of the NB-IoT module is used to access the network;

[0013] S2: The MCU processor sends a connection request with the APP verification code to the PC or remote server, and the PC or remote server determines whether the APP verification code is correct;

[0014] S3: If the APP verification code is correct, the PC or remote server determines whether the MCU processor receives an update instruction during the waiting delay period. If an update is required, the process proceeds to step S4; otherwise, the process proceeds to step S8; if the APP verification code is incorrect, the process determines that the MCU processor needs to be updated and the process proceeds to step S4;

[0015] S4: The PC or remote server sends a connection command containing a new APP verification code to the MCU processor. After receiving the connection command from the PC or remote server, the MCU processor stops timing, the BootLoader is successfully connected, and the MCU processor replies with a connection response;

[0016] S5: The PC or remote server parses the binary file of the APP application into a combination of addresses and data, and sends the addresses and data to the MCU processor in a package through a write sector command;

[0017] S6: The MCU processor receives the data sent by the PC or the remote server, and performs a CRC check after receiving the data. If the result is correct, the corresponding flash area is erased and the binary file of the application is written. If the result is wrong, the processor returns to step S5 to request resending the data.

[0018] S7: After the program is successfully written, the PC or remote server sends a write IAP verification code command containing the IAP verification code to the MCU processor. After receiving the command, the MCU processor writes the IAP verification code in the flash area.

[0019] S8: Verify in the MCU processor whether the Bootloader meets the preset conditions for entering the application program. If yes, restore all external devices, turn off all interrupts, jump to the new reset interrupt reset vector, execute the APP reset interrupt service program, and then jump to the main function to run the application program. Otherwise, go to step S9;

[0020] S9: The Bootloader does not meet the preset conditions for entering the application. If the MCU processor is in a state of receiving an update instruction, it waits to receive a new command; if the MCU processor is in a state of not receiving an update instruction, it enters an infinite loop function.

[0021] Preferably, the NB module and the MCU processor are connected via UART, and the device uses the AT instruction set to send data and respond via the serial port, and all data instructions and responses are transmitted in the AT instruction set format.

[0022] Preferably, the program upgrade system also includes an error checking mechanism during the upgrade process, specifically: when the MCU processor receives an instruction, it parses the instruction and returns a response, the value of the last byte in the response corresponds to the status of the instruction, and the value of the last byte corresponds to whether the response is executed successfully or not. The MCU processor counts the number of errors, and if the number of errors exceeds a preset number, the MCU processor restarts.

[0023] The present invention also provides a user equipment, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the program upgrade method based on the NB-IoT module when executing the computer program.

[0024] The present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of the program upgrade method based on the NB-IoT module.

[0025] The beneficial effects of the present invention are:

[0026] 1. Considering the layout and cost, it is proposed to use NB-IoT with low power consumption and wide coverage for remote program upgrade, and upload data directly to the cloud, which is very accurate and compatible with the BootLoader using the original bus protocol to realize program download, while retaining its use and expanding the scope of operation, so that both on-site and remote program upgrades can be realized;

[0027] 2. The present invention ensures data accuracy and stability through the small data volume and repeated transmission of NB-IoT, and completes the burning of the controller program.

[0028] 3. The present invention displays the upgrade status in real time by monitoring the data transmission status of the cloud platform and the software development on the server side, which can promptly detect data loss or transmission errors and establish an error handling mechanism. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 Schematic diagram of system connection according to an embodiment of the present invention.

[0030] Figure 2 FIG. 4 is a schematic diagram of NB module connection according to an embodiment of the present invention. DETAILED DESCRIPTION

[0031] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0032] like Figure 1 As shown, a program upgrade system based on the NB-IoT module includes an MCU processor, an NB module, an IoT platform, a remote server, a CAN transceiver, a CAN port, a USB to CAN module, a USB to serial port module and a PC.

[0033] The PC is connected to the USB-to-CAN module and the USB-to-serial port module via a USB cable. The USB-to-CAN module is connected to the CAN transceiver via the CAN port. The CAN port and the CAN transceiver are connected via two signal lines, CAN_H and CAN_L. The USB-to-serial port module is connected to the UART1 pin of the MCU processor via UART_RX and UART_TX. The MCU processor is connected to the NB module. The NB module is connected to the IoT platform via the base station and the core network. The IoT platform is connected to the remote server.

[0034] As an embodiment of the present invention, Figure 2 As shown, the NB module includes an NB-IoT module, a filter antenna circuit, a reset circuit and a SIM card holder. The NB-IoT module is connected to the filter antenna circuit, the reset circuit and the SIM card holder respectively, and the UART2 pin of the MCU processor is connected to the NB-IoT module through UART.

[0035] As an embodiment of the present invention, the MCU processor includes a flash storage area, and the flash storage area includes a Boot loader storage area, an application APP storage area, and a marking area from top to bottom; the Boot loader storage area includes a Bootloader vector table and a Bootloader program, the application APP storage area includes an interrupt vector table and an APP program of the App relocated at the beginning of the main function, and the marking area includes an APP verification code and an IAP verification code.

[0036] This system can use CAN protocol or UART protocol to implement the program upgrade process of on-site connection, and can also realize remote control program upgrade through remote server, cloud platform and NB module.

[0037] The embodiment of the present invention further provides a program upgrade method based on the NB-IoT module, using the above-mentioned program upgrade system based on the NB-IoT module, the host computer described below is a PC or a remote server, and both the PC and the remote server include a host computer program, including the following steps:

[0038] 1. MCU is powered on and reset, and the entry address of the program is obtained from the reset vector of the Bootloader vector table, that is, the entry address of the Bootloader. After the initialization and interrupt setting of necessary hardware peripherals (including CAN, uart, flash, timer, etc.), the BootLoader protocol is initialized, and then the AT command is connected to the network to complete all preparations. After the MCU is reset, it starts timing (that is why the system timer is needed), sends a connection request (including the APP verification code, which is equivalent to the version number of the application program), and then enters a loop to wait for the host computer command. The command can come from the original connection port, or the command received by the NB module from the host computer server program. When using the PC-CAN transceiver, the interrupt is set to open the corresponding CAN receive interrupt that needs to be connected, and when using the PC-USB to serial port connection, the corresponding UART receive interrupt is opened; when using the remote upgrade system of the NB module, the UART receive interrupt is opened, and the instructions received in the interrupt are extracted from the receiving format corresponding to the AT instruction, and then the Bootloader protocol is parsed and executed.

[0039] 2. The host computer checks the APP verification code and will reply a correct or wrong response (including the correct APP verification code) to the MCU. If it is correct and the program needs to be updated, the host computer sends a connection command containing the new APP verification code (i.e., a correct response). The MCU receives the connection command from the host computer within 2s (the time can be programmed and depends on the specific situation), indicating that the BootLoader is successfully connected. The MCU replies with a connection response. If the waiting command in the communication cycle times out within 2s (the time can be programmed and depends on the specific situation), and the MCU does not receive the connection command from the host computer, then enter step 4; if the APP verification code is wrong, the host computer sends a connection command containing the correct APP verification code (i.e., an error response), and the MCU receives the connection command from the host computer, indicating that the BootLoader is successfully connected. The MCU replies with a connection response. The program can only be downloaded if the connection is successful within 2 seconds of booting (the time can be programmed and depends on the specific situation), and then the BootLoader program waits for the arrival of other commands.

[0040] 3. After that, the host computer follows the established protocol instructions, and the MCU executes the BootLoader's command to erase the flash sector. After receiving the firmware binary file sent by the host computer, it performs a verification. Every time data is received, a data verification calculation is performed, and the calculated verification value is compared with the received verification value. If they are the same, it means that the acceptance is correct. The flash is burned into the APP area once, and the burning result is responded to the host computer; when the host computer receives the response of the last burning result, it sends the write IAP verification code instruction (with IAP verification code) instruction to the MCU, and the MCU receives the instruction and writes the IAP verification code in the flash area. When writing the sector code through the Bootloader, the Iap verification code is not burned. After the entire firmware program is successfully written, the "write IAP verification code command" is used to write to the address, indicating that the updated program is completed correctly.

[0041] 4. Check the four verification conditions for Bootloader to enter the application. The conditions are as follows:

[0042] 1) The stack pointer is within the set data memory range;

[0043] 2) Whether there is an application, that is, whether the application code space contains valid binary executable code;

[0044] 3) The APP verification code is correct;

[0045] 4) The IAP verification code is correct;

[0046] If the verification code is correct, jump. If the verification code is incorrect:

[0047] a) When the MCU receives the connection command, it waits to receive a new command.

[0048] b) When the MCU does not receive the connection command, it enters the infinite loop function.

[0049] When the above verification conditions are met, restore the initial values ​​of all peripherals and disable all interrupts using peripherals. Jump to the reset vector table of the APP, take out the address of the reset interrupt vector of the APP, execute the reset interrupt service program of the APP, and finally jump to the main function of the APP. Relocate the interrupt vector table at the beginning of the main function, and write the APP verification code at the end of the APP program, indicating that the entire APP program of this version can run normally.

[0050] During the program upgrade process, the error check mechanism is enabled. When the MCU processor receives the instruction, it parses the instruction and responds. The value of the last byte in the response corresponds to the status of the instruction, and the value of the last byte corresponds to whether the response is executed successfully or not. The MCU processor counts the number of errors. If the number of errors exceeds the preset number, the MCU processor restarts. For example, in the command to jump to APP execution, the last byte of the response sent by the MCU is BYTE7: 0x00-jump normal, 0x01-verification code error, 0x02-stack address error, 0x03-no application; the last byte of the response to the write sector command is BYTE7: 0x0-write successful, 01-flash write failure, 03-verification failure, 0x10-command error, etc.

[0051] In the above steps, the system is powered on and starts to enter the BootLoader. After starting from the Bootloader, some necessary initializations will be performed on the system, such as flash, CAN, UART, etc. The NB module is connected to the IoT platform. After the remote server receives the notification from the IoT platform, data can be sent and received normally.

[0052] The NB module and the controller MCU are connected via UART, and the device uses the AT command set to send data and respond via the serial port. All data commands and responses are transmitted in the AT command set format. Commands and responses during the transmission process.

[0053] Although the transmission rate of NB-IoT is not as fast as that of wireless networks such as 4G, it is fully sufficient for flash programming of motor controller programs.

[0054] As an embodiment of the present invention, a user equipment is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the steps of the above method are implemented when the processor executes the computer program.

[0055] As an embodiment of the present invention, the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0056] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can still modify the technical solutions described in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or perform equivalent replacements on some of the technical features thereof; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention. They should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A program upgrade method based on an NB-IoT module, implemented according to a program upgrade system based on an NB-IoT module, characterized in that: The program upgrade system based on the NB-IoT module includes: an MCU processor, the MCU processor is connected to the NB module, the NB module is connected to the IoT platform through the base station and the core network, and the IoT platform is communicatively connected to the remote server; the MCU processor is connected to the CAN transceiver, the CAN transceiver is connected to the CAN port, the CAN port is connected to the PC through the USB to CAN module and the USB cable, and the PC is also connected to the MCU processor through the USB cable and the USB to serial port module; the MCU processor includes a flash storage area, and the flash storage area includes a Bootloader storage area, an application APP storage area, and a marking area from top to bottom; the Bootloader storage area includes a Bootloader vector table and a Bootloader program, the application APP storage area includes an interrupt vector table and an APP program of the App relocated at the beginning of the main function, and the marking area includes an APP verification code and an IAP verification code; The CAN transceiver is connected to the CAN interface of the MCU through CAN_RX and CAN_TX, the CAN transceiver is connected to the CAN port through CAN_H and CAN_L, and the USB to serial port module is connected to the UART1 pin of the MCU processor through UART_RX and UART_TX; The NB module includes a NB-IoT module, a filter antenna circuit, and a SIM card holder. The NB-IoT module is connected to the filter antenna circuit and the SIM card holder respectively. The NB-IoT module is connected to the UART2 pin of the MCU processor via UART. The program upgrade method based on the NB-IoT module includes the following steps: S1: The MCU processor is powered on and reset, and the program entry address is obtained from the reset vector of the Bootloader vector table. The flash, CAN, UART and system timer are initialized, and the interrupt is set. The system timer starts timing; the Bootloader protocol is initialized, and the AT command of the NB-IoT module is used to access the network; S2: The MCU processor sends a connection request with the APP verification code to the PC or remote server, and the PC or remote server determines whether the APP verification code is correct; S3: If the APP verification code is correct, the PC or remote server determines whether the MCU processor receives an update instruction during the waiting delay period. If an update is required, the process proceeds to step S4; otherwise, the process proceeds to step S8; if the APP verification code is incorrect, the process determines that the MCU processor needs to be updated and the process proceeds to step S4; S4: The PC or remote server sends a connection command containing a new APP verification code to the MCU processor. After receiving the connection command from the PC or remote server, the MCU processor stops timing, the BootLoader is successfully connected, and the MCU processor replies with a connection response; S5: The PC or remote server parses the binary file of the APP application into a combination of addresses and data, and sends the addresses and data to the MCU processor in a package through a write sector command; S6: The MCU processor receives the data sent by the PC or the remote server, and performs a CRC check after receiving the data. If the result is correct, the corresponding flash area is erased and the binary file of the application is written. If the result is wrong, the processor returns to step S5 to request resending the data. S7: After the program is successfully written, the PC or remote server sends a write IAP verification code command containing the IAP verification code to the MCU processor. After receiving the command, the MCU processor writes the IAP verification code in the flash mark area; S8: Verify in the MCU processor whether the Bootloader meets the preset conditions for entering the application program. If yes, restore all external devices, turn off all interrupts, jump to the new reset interrupt reset vector, execute the APP reset interrupt service program, and then jump to the main function to run the application program. Otherwise, go to step S9; S9: The Bootloader does not meet the preset conditions for entering the application. If the MCU processor is in a state of receiving an update instruction, it waits to receive a new command; if the MCU processor is in a state of not receiving an update instruction, it enters an infinite loop function.

2. The program upgrade method based on the NB-IoT module according to claim 1, characterized in that: Said The NB module and MCU processor are connected through UART. The device uses the AT instruction set to send data and respond through the serial port. All data instructions and responses are transmitted in the AT instruction set format.

3. The program upgrade method based on the NB-IoT module according to claim 1, characterized in that: The program upgrade system also includes an error checking mechanism during the upgrade process, specifically: when the MCU processor receives an instruction, it parses the instruction and responds, the value of the last byte in the response corresponds to the status of the instruction, and the value of the last byte corresponds to whether the response is executed successfully or not. The MCU processor counts the number of errors, and if the number of errors exceeds a preset number, the MCU processor restarts.

4. A user equipment, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 are implemented.

5. A computer-readable storage medium storing a computer program, 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.