Upgrading method based on RS485 bus
By using an RS485 bus-based upgrade method, leveraging the Modbus-RTU protocol and point-to-point communication mode, and combining firmware signature verification, remote upgrades of terminal devices in high-voltage scenarios were achieved. This solved the security and efficiency issues of equipment upgrades in high-voltage scenarios, and improved upgrade efficiency and reliability.
Patent Information
- Application Number
- CN202511012787.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-22
- Publication Date
- 2025-11-07
AI Technical Summary
Upgrading terminal equipment software in high-voltage scenarios presents challenges such as low security, difficult maintenance, low efficiency, and potential safety risks. In particular, when upgrading equipment in substations and distribution rooms, manual operation is required, which carries the risk of equipment misoperation.
The upgrade method adopts RS485 bus-based approach. Through the connection between the master control device and the terminal device, the Modbus-RTU protocol is used to read the device status, send control signals to prevent bus conflicts, and perform the upgrade through point-to-point communication mode. The application is transmitted using Xmodem or Ymodem protocol, and firmware signature verification is combined to ensure the reliability of the upgrade.
It enables remote upgrades of multiple terminal devices without entering high-voltage areas, improving upgrade efficiency and reliability, avoiding the safety risks of manual operation, and increasing upgrade efficiency by 60%.
Smart Images

Figure CN120915664A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of device remote upgrading and maintenance, and more particularly, to an upgrading method based on RS485 bus. BACKGROUND
[0002] With the development of the intelligentization and digitization of power grids, online monitoring systems are increasingly widely applied in power grids. Various types of sensors, as terminal devices of the systems, have functions of monitoring device parameters, environmental parameters, device linkage, etc., and play a very important role in the safe production, device operation and maintenance, and device repair of power grid companies.
[0003] However, at present, a large number of terminal devices are arranged in high-voltage scenes such as transformer substations and power distribution rooms. If software defects occur or application functions are increased, the terminal devices need to be upgraded. When the construction personnel upgrade the terminal devices, they need to enter the high-voltage room to manually restart and manually wire the terminal devices for upgrading and maintenance. However, this may cause the following problems and risks: first, the transformer substation and the power distribution room are high-voltage scenes or dangerous areas. In order to enter the station for maintenance, an operation approval procedure and a guardian are required. The safety of terminal device upgrading is low, the maintenance is difficult, and it is difficult to upgrade the device alone after the device is put into operation. In addition, the upgrading method needs to manually power off and restart the terminal devices one by one, disconnect the original connection line to the host, and use a notebook or other tool to individually connect each terminal device for upgrading and debugging. This method has problems such as long time and low efficiency. Finally, during the power-off and restart process, if the five-prevention logic operation is not standardized, it may cause electric shock or misoperation of primary equipment, which may cause hidden dangers to personnel safety and equipment operation.
[0004] Therefore, it is necessary to provide an upgrading method based on RS485 bus to solve the above problems. SUMMARY
[0005] The present application provides an upgrading method based on RS485 bus to overcome at least one of the defects of the prior art.
[0006] To solve the above technical problems, the technical scheme of the present application is as follows: an upgrading method based on RS485 bus, comprising a master control device and a plurality of terminal devices, the master control device and the plurality of terminal devices being connected through an RS485 bus, comprising the following steps:
[0007] Step 1: The master control device reads the running state of all terminal devices to confirm that the terminal devices on the RS485 bus are normally running in the application program.
[0008] Step 2: The master control device sends a signal with attached data to all terminal devices to prohibit all terminal devices from responding, so as to avoid bus conflicts.
[0009] Step 3, the master device sends a control signal to the target terminal device through a point-to-point communication mode, controls the target terminal device to switch to an upgrade boot program mode, and downloads the upgraded application program to a reserved buffer area;
[0010] Step 4: The upgrade boot program verifies the validity of the firmware signature of the received upgraded application program, and only when the firmware signature verification of the upgraded application program passes, the upgraded application program is allowed to be downloaded from the buffer area to the application program area. If the verification fails, the terminal device will stay in the upgrade boot program to wait for re-upgrade or continue to run the previous program;
[0011] Step 5: The master device repeats steps 3 and 4 in turn for the remaining terminal devices until all terminal devices complete the upgrade.
[0012] Further, in step 1, the master device reads the running state of all terminal devices through the Modbus-RTU protocol to confirm that the terminal devices on the RS485 bus are running normally in the application program.
[0013] Further, in step 2, the master device sends function code 0x6C through Modbus broadcast mode, and attaches data 0x00 to disable all devices from responding to avoid bus conflicts.
[0014] Further, in step 3, the following steps are included:
[0015] Step 31, if the terminal device receives a user input upgrade instruction, it enters the upgrade mode (PROG), and the master device sends function code 0x6D to the Modbus address of the target terminal device through a point-to-point communication mode, instructing it to switch to the upgrade boot program mode.
[0016] Step 32, the target terminal device switches to the upgrade boot program mode according to the function code 0x6D sent by the master device, and downloads the upgraded application program to the reserved buffer area.
[0017] Further, in step 32, the Xmodem protocol can be used to transmit and download the upgraded application program.
[0018] Further, in step 32, the Ymodem protocol can be used to transmit and download the upgraded application program.
[0019] Further, in step 4, the following steps are included:
[0020] Step 41, the upgrade boot program verifies the validity of the firmware signature of the upgraded application program received, and only when the firmware signature of the upgraded application program is verified, the upgraded application program is allowed to be downloaded from the buffer area to the application program area, if the verification fails, the terminal device will stay in the upgrade boot program to wait for re-upgrade or continue to run the previous program;
[0021] Step 42, when the terminal device is restarted, if the terminal device does not receive the instruction input by the user, it automatically enters the running mode (RUN), and the upgrade boot program first checks whether there is an upgraded application program in the buffer area that has not been upgraded, if there is an upgraded application program that has not been upgraded, and the signature is passed in the re-verification, it is also downloaded to the application program area;
[0022] If there is no upgraded application program that has not been upgraded, it is directly judged whether the application program in the application program area is valid, if yes, it is executed, otherwise, it is stopped.
[0023] Further, in step 42, when the terminal device is restarted, it is first judged whether the user presses the Esc key, if yes, it enters the Boot mode and prints a menu, waits for the user to input an instruction through a serial port, and judges whether to enter the upgrade mode (PROG) or the running mode (RUN) according to the instruction input by the user.
[0024] Further, when the terminal device is restarted, it is first waited for 1-10 seconds to judge whether the user presses the Esc key.
[0025] Further, the plurality of terminal devices are SF6 sensors or transformer temperature sensors, and in actual application, the terminal device can also be other types of sensors, which are easily thought of by those skilled in the art.
[0026] Compared with the prior art, the beneficial effects of the technical scheme of the present application are:
[0027] The upgrade method based on the RS485 bus disclosed in the present application supports RS485 bus upgrade and maintenance, uses the original device interface, and can be upgraded and maintained without external connection of other interfaces, can support up to 247 devices, and the devices can be different types of sensing devices, improves product applicability and maintainability, avoids entering dangerous places such as high-voltage rooms and mine fields where personnel are strictly prohibited, can remotely upgrade and maintain the product, improves upgrade efficiency, and does not need to power off and restart each device and connect data, compared with the traditional upgrade efficiency, the upgrade efficiency is improved by 60%, the upgrade and maintenance reliability is improved, and multiple verifications are used in the upgrade process to ensure the reliability of the upgrade and maintenance. BRIEF DESCRIPTION OF DRAWINGS
[0028] Figure 1This is a flowchart of the upgrade method based on RS485 bus of the present invention;
[0029] Figure 2 This is a schematic diagram showing the distribution of the application program and boot upgrade program of the present invention in the internal Flash memory;
[0030] Figure 3 This is a flowchart of the upgrade boot program of the present invention;
[0031] Figure 4 This is a schematic diagram of the application flow of the present invention. Detailed Implementation
[0032] The accompanying drawings are for illustrative purposes only and should not be construed as limiting the scope of this patent. To better illustrate this embodiment, some components in the drawings may be omitted, enlarged, or reduced, and do not represent the actual dimensions of the product. It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.
[0033] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation" and "connection" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances. The technical solution of this invention will be further described below with reference to the accompanying drawings and embodiments.
[0034] like Figures 1-4 As shown, an upgrade method based on an RS485 bus includes a main control device and multiple terminal devices, wherein the main control device and the multiple terminal devices are connected via an RS485 bus, and includes the following steps:
[0035] Step 1: The main control device reads the operating status of all terminal devices to confirm that all terminal devices on the RS485 bus are running normally in the application.
[0036] Step 2: The main control device sends a signal with attached data to all terminal devices to prevent all terminal devices from responding and avoid bus conflicts.
[0037] Step 3: The main control device sends a control signal to the target terminal device through point-to-point communication mode, controls the target terminal device to switch to the upgrade boot program mode, and downloads the upgraded application to the reserved buffer area;
[0038] Step 4: The upgrade boot program verifies the firmware signature of the received upgraded application program for validity, and only when the firmware signature of the upgraded application program is verified, the upgraded application program is allowed to be downloaded from the buffer area to the application program area, if the verification fails, the terminal device will stay in the upgrade boot program to wait for re-upgrade or continue to run the previous program;
[0039] Step 5: The master device repeats steps 3 and 4 in turn for the remaining terminal devices until all terminal devices complete the upgrade.
[0040] In step 1 of the application, the master device reads the running state of all terminal devices through the Modbus-RTU protocol to confirm that the terminal devices on the RS485 bus are running normally in the application program.
[0041] In step 2 of the application, the master device sends function code 0x6C through Modbus broadcast mode, and attaches data 0x00 to disable all devices from responding to avoid bus conflicts.
[0042] In step 3 of the application, the following steps are included:
[0043] Step 31, if the terminal device receives the user input upgrade instruction, it enters the upgrade mode (PROG), and the master device sends function code 0x6D to the Modbus address of the target terminal device through point-to-point communication mode, indicating that it switches to the upgrade boot program mode.
[0044] Step 32, the target terminal device switches to the upgrade boot program mode according to the function code 0x6D sent by the master device, and downloads the upgraded application program to the reserved buffer area.
[0045] In step 32 of the application, Xmodem or Ymodem protocol can be selected to transmit and download the upgraded application program.
[0046] In step 4 of the application, the following steps are included:
[0047] Step 41, the upgrade boot program verifies the firmware signature of the received upgraded application program for validity, and only when the firmware signature of the upgraded application program is verified, the upgraded application program is allowed to be downloaded from the buffer area to the application program area, if the verification fails, the terminal device will stay in the upgrade boot program to wait for re-upgrade or continue to run the previous program;
[0048] Step 42, when the terminal device is restarted, if the terminal device does not receive the instruction input by the user, it automatically enters the running mode (RUN), and the upgrade bootloader first checks whether there is an upgraded application program with incomplete upgrade in the buffer, if there is an upgraded application program with incomplete upgrade, and the signature passes the re-checking, it is also downloaded to the application program area;
[0049] If there is no upgraded application program with incomplete upgrade, it is directly judged whether the application program in the application program area is valid, if yes, it is executed, otherwise, it is stopped running.
[0050] In step 42 of the application, when the terminal device is restarted, first wait for 3 seconds, judge whether the user presses the Esc key, if yes, enter the Boot mode and print the menu, wait for the user to input the instruction through the serial port, and judge whether to enter the upgrade mode (PROG) or the running mode (RUN) according to the instruction input by the user.
[0051] In the application, the application program needs to have the basic Modbus-RTU function, and expand the function code on this basis, such as 0x6C, 0x6D, 0x6C, which is used to control the device response, and 0x6D is used to control the device to enter the upgrade bootloader.
[0052] In the specific implementation of the application, it is suitable for environmental monitoring in power distribution rooms, power plants and substations, and the main control device processes batch upgrade of the lower end sensors, according to the method of the application, the main control device and the plurality of terminal devices, i.e. the lower end sensors, are connected through the RS485 bus, and the communication protocol and the file transfer protocol are used in the point-to-point communication mode of the RS485 bus to realize the upgrade and maintenance of the software of the plurality of lower end sensors in a non-local manner, wherein the sensors include but are not limited to SF6 sensors, transformer temperature measurement sensors, etc., and the state monitoring of the device can also be realized.
[0053] In the figure, the position relationship is only used for example description and cannot be understood as a limitation of the patent; obviously, the above embodiments of the application are only examples for clearly illustrating the application, and are not a limitation of the embodiments of the application. For ordinary skilled persons in the art, other different forms of changes or variations can be made on the basis of the above description. Here, it is not necessary and impossible to exhaust all the embodiments. Any modification, equivalent replacement and improvement made within the spirit and principles of the application shall be included in the protection scope of the claims of the application.
Claims
1. A RS485 bus-based upgrading method, comprising a master control device and a plurality of terminal devices, the master control device and the plurality of terminal devices being connected through a RS485 bus, characterized in that: The method comprises the following steps: Step 1, the master device reads the running state of all terminal devices to confirm that the terminal devices on the RS485 bus are normally running in the application program; Step 2, the master device sends a signal with attached data to all terminal devices to disable all terminal devices from responding, thereby avoiding bus conflicts; Step 3, the master device sends a control signal to the target terminal device through a point-to-point communication mode to control the target terminal device to switch to an upgrade boot program mode and download the upgraded application program to a reserved buffer area; Step 4: the upgrade boot program verifies the validity of the firmware signature of the received upgraded application program, and only when the firmware signature of the upgraded application program passes the verification, the upgraded application program is allowed to be downloaded from the buffer area to the application program area, if the verification fails, the terminal device will stay in the upgrade boot program to wait for re-upgrade or continue to run the previous program; Step 5: the master device repeats steps 3 and 4 in turn for the remaining terminal devices until all terminal devices complete the upgrade.
2. The RS485 bus-based upgrade method according to claim 1, characterized in that: In step 1, the master device reads the running state of all terminal devices through the Modbus-RTU protocol to confirm that the terminal devices on the RS485 bus are normally running in the application program.
3. The RS485 bus-based upgrade method of claim 1, wherein: In step 2, the master device sends a function code 0x6C through the Modbus broadcast mode and attaches data 0x00 to disable all devices from responding, thereby avoiding bus conflicts.
4. The RS485 bus-based upgrade method of claim 1, wherein: In step 3, the following steps are included: Step 31, if the terminal device receives the upgrade instruction input by the user, it enters the upgrade mode (PROG), and the master device sends a function code 0x6D to the Modbus address of the target terminal device through a point-to-point communication mode to instruct it to switch to the upgrade boot program mode; Step 32, the target terminal device switches to the upgrade boot program mode according to the function code 0x6D sent by the master device and downloads the upgraded application program to the reserved buffer area.
5. The RS485 bus-based upgrade method according to claim 4, characterized in that: In step 32, the Xmodem protocol can be selected to transmit and download the upgraded application program.
6. The RS485 bus-based upgrade method according to claim 4, characterized in that: In step 32, the Ymodem protocol can be selected to transmit and download the upgraded application program.
7. The RS485 bus-based upgrade method of claim 1, wherein: In step 4, The following steps are included: Step 41, the upgrade boot program verifies the validity of the firmware signature of the received upgraded application program, and only when the firmware signature of the upgraded application program passes the verification, the upgraded application program is allowed to be downloaded from the buffer area to the application program area, if the verification fails, the terminal device will stay in the upgrade boot program to wait for re-upgrade or continue to run the previous program; Step 42, when the terminal device is running again, if the terminal device does not receive the instruction input by the user, it automatically enters the running mode (RUN), the upgrade boot program first checks whether there is an upgraded application program that has not completed the upgrade in the buffer area, if there is an upgraded application program that has not completed the upgrade and the signature passes the verification again, it is also downloaded to the application program area; If there is no upgraded application program to be upgraded, it is directly judged whether the application program in the application program area is valid, and if valid, it is jumped to execute, otherwise, it is stopped to run.
8. The RS485 bus-based upgrade method according to claim 7, characterized in that: In the step 42, when the terminal device is restarted, it is firstly judged whether the Esc key is pressed by the user, if yes, it enters the Boot mode and prints a menu, waits for the user to input a command through a serial port, and judges whether to enter the upgrade mode (PROG) or the running mode (RUN) according to the command input by the user.
9. The RS485 bus-based upgrade method according to claim 8, characterized in that: When the terminal device is restarted, it firstly waits for 1-10 seconds, and judges whether the Esc key is pressed by the user.
10. The RS485 bus-based upgrade method of claim 1, wherein: The plurality of terminal devices are SF6 sensors or transformer temperature measuring sensors.
Citation Information
Patent Citations
Device upgrading method and apparatus, to-be-upgraded device and device upgrading system
CN113986299A
BootLoader program online upgrading method, control unit and new energy automobile
CN116302021A
Remote upgrading method and device of end equipment, equipment and storage medium
CN117519753A
Firmware upgrading method and system for RS485 network equipment
CN117596235A
A method and apparatus for upgrading a system firmwareby using an universal serial bus
KR1020030073824A