Method and terminal for entering upgrade mode based on monitoring Ethernet frame

By monitoring Ethernet frames in front of the TCP/IP protocol stack, judging and processing upgrade frames, the problem of udp-socket occupying RAM resources on the MCU is solved, achieving resource saving and efficient firmware upgrades.

CN119341936APending Publication Date: 2025-01-21CONTEMPORARY NEBULA TECH ENERGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411324270.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-23
Publication Date
2025-01-21

AI Technical Summary

Technical Problem

On resource-constrained MCUs, a udp-socket is specially created to listen for upgrade commands for a long time, resulting in wasted RAM resources.

Method used

In front of the TCP/IP protocol stack, the Ethernet frame is monitored to determine whether it is an upgrade frame. If it is an upgrade frame, the application layer is notified for processing, thus avoiding the memory occupation of udp-socket.

Benefits of technology

It effectively saves memory resources and avoids the memory occupation caused by udp-socket. It is suitable for firmware upgrades of small embedded devices with limited resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119341936A_ABST
    Figure CN119341936A_ABST
Patent Text Reader

Abstract

The invention discloses a method and terminal for entering an upgrade mode based on monitoring an Ethernet frame, and the method comprises the steps: monitoring the Ethernet frame before a TCP / IP protocol stack, and judging whether the Ethernet frame is an upgrade frame; if the Ethernet frame is an upgrading frame, notifying an application layer to obtain upgrading firmware and entering an upgrading mode, otherwise, inputting the upgrading frame into a TCP / IP protocol stack; according to the method and the device, a udp-socket does not need to be created on an application layer to monitor the upgrading command, monitoring of the Ethernet frame and judgment of the upgrading frame are performed before the Ethernet frame enters the TCP / IP protocol stack, and if the Ethernet frame is the upgrading frame, the application layer is notified to process, so that memory occupation caused by the udp-socket is effectively avoided, and memory resources are saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of firmware upgrade, and in particular to a method and a terminal for entering an upgrade mode based on monitoring Ethernet frames. Background Art

[0002] Embedded terminal devices need to have upgrade capabilities due to function changes, software bug fixes, etc.

[0003] For remote upgrade, the terminal device generally connects to the cloud platform through MQTT to report data. When an upgrade is required, the cloud platform sends an upgrade command through MQTT, and the upgrade command contains the URL of the new firmware. After receiving the upgrade command, the device uses the URL to obtain the new firmware from the server through https, and the upgrade is successful.

[0004] Local upgrade, in order to be compatible with remote upgrade, the terminal device creates a udp-socket at the application layer to receive the upgrade command issued by the PC host computer. The upgrade command contains the URL of the new firmware. After receiving the upgrade command, the device uses the URL to obtain the new firmware from the PC through https, and then the upgrade is successful. Its architecture can be referred to Figure 1 shown.

[0005] like Figure 1 As shown in the figure, the existing solution is generally to create a udp-socket at the application layer to listen for upgrade commands. Upgrading is a low-frequency operation, so on an MCU with small RAM resources, it is a waste of RAM to create a udp-socket specifically for long-term monitoring of upgrade commands. Summary of the invention

[0006] The technical problem to be solved by the present invention is to provide a method and a terminal for entering an upgrade mode based on monitoring Ethernet frames, thereby saving memory resources.

[0007] In order to solve the above technical problems, the technical solution adopted by the present invention is:

[0008] A method for entering an upgrade mode based on monitoring Ethernet frames, comprising the steps of:

[0009] S1. Before the TCP / IP protocol stack, monitor the Ethernet frame to determine whether the Ethernet frame is an upgrade frame;

[0010] S2. If the Ethernet frame is an upgrade frame, the application layer is notified to obtain the upgrade firmware and enter the upgrade mode; otherwise, the upgrade frame is put into the TCP / IP protocol stack.

[0011] In order to solve the above technical problems, another technical solution adopted by the present invention is:

[0012] A terminal that enters an upgrade mode based on monitoring Ethernet frames comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:

[0013] S1. Before the TCP / IP protocol stack, monitor the Ethernet frame to determine whether the Ethernet frame is an upgrade frame;

[0014] S2. If the Ethernet frame is an upgrade frame, the application layer is notified to obtain the upgrade firmware and enter the upgrade mode; otherwise, the upgrade frame is put into the TCP / IP protocol stack.

[0015] The beneficial effects of the present invention are as follows: a method and a terminal for entering an upgrade mode based on monitoring Ethernet frames of the present invention do not need to create a udp-socket at the application layer to monitor the upgrade command, but monitor the Ethernet frame before the Ethernet frame enters the TCP / IP protocol stack, and judge the upgrade frame. If it is an upgrade frame, the application layer is notified to process it, which effectively avoids the memory occupation caused by the udp-socket and saves memory resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 This is an example diagram of the architecture of the prior art in the background technology of the present invention;

[0017] Figure 2 An exemplary architecture diagram of a method for entering an upgrade mode based on monitoring Ethernet frames according to an embodiment of the present invention;

[0018] Figure 3 This is a flowchart of a method for entering an upgrade mode based on monitoring Ethernet frames according to an embodiment of the present invention;

[0019] Figure 4 A structural diagram of a terminal that enters an upgrade mode based on monitoring Ethernet frames according to an embodiment of the present invention;

[0020] Description of labels:

[0021] 1. A terminal that enters an upgrade mode based on monitoring Ethernet frames; 2. A processor; 3. A memory. DETAILED DESCRIPTION

[0022] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.

[0023] Please refer to Figure 2 as well as Figure 3 , a method for entering an upgrade mode based on monitoring Ethernet frames, comprising the steps of:

[0024] S1. Before the TCP / IP protocol stack, monitor the Ethernet frame to determine whether the Ethernet frame is an upgrade frame;

[0025] S2. If the Ethernet frame is an upgrade frame, the application layer is notified to obtain the upgrade firmware and enter the upgrade mode; otherwise, the upgrade frame is put into the TCP / IP protocol stack.

[0026] From the above description, it can be seen that the beneficial effects of the present invention are: a method of entering an upgrade mode based on listening to Ethernet frames of the present invention does not need to create a udp-socket at the application layer to listen to the upgrade command, but listens to the Ethernet frame before the Ethernet frame enters the TCP / IP protocol stack, and makes a judgment on the upgrade frame. If it is an upgrade frame, the application layer is notified to process it, which effectively avoids the memory occupation caused by the udp-socket and saves memory resources.

[0027] Further, step S1 includes:

[0028] When the MAC driver receives the Ethernet frame transmitted from the physical layer, it determines whether the Ethernet frame is an upgrade frame.

[0029] From the above description, it can be seen that after the MAC layer receives the Ethernet frame transmitted by the PHY physical layer, it determines whether it is an upgrade frame, without the need to implement it through udp-socket.

[0030] Further, determining whether the Ethernet frame is an upgrade frame includes:

[0031] An identification code match is performed on the Ethernet frame. If the identification code of the Ethernet frame belongs to an upgrade frame identification code, the Ethernet frame is identified as an upgrade frame.

[0032] From the above description, it can be seen that the upgrade frame has a specific identification code. By matching the identification code, it is possible to determine whether it is an upgrade frame accurately and efficiently.

[0033] Further, the application layer is notified to obtain the upgrade firmware and enter the upgrade mode, including:

[0034] Parsing the upgrade frame to obtain the firmware acquisition address therein;

[0035] Notify the application layer to obtain the upgrade firmware through HTTPS according to the firmware acquisition address;

[0036] Reset to enter boot, and perform firmware upgrade according to the upgrade firmware.

[0037] It can be seen from the above description that after the upgrade frame is identified, the firmware acquisition address therein is parsed, the application layer is directly notified to acquire the upgrade firmware, and the upgrade is performed according to the acquired upgrade firmware.

[0038] Furthermore, the TCP / IP protocol stack adopts the LWIP protocol stack.

[0039] From the above description, we can see that the TCP / IP protocol stack chooses to use the LWIP protocol stack. The LWIP protocol stack greatly reduces the occupancy of RAM and ROM while maintaining the core functions of TCP / IP.

[0040] Please refer to Figure 4 , a terminal that enters an upgrade mode based on monitoring Ethernet frames, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:

[0041] S1. Before the TCP / IP protocol stack, monitor the Ethernet frame to determine whether the Ethernet frame is an upgrade frame;

[0042] S2. If the Ethernet frame is an upgrade frame, the application layer is notified to obtain the upgrade firmware and enter the upgrade mode; otherwise, the upgrade frame is put into the TCP / IP protocol stack.

[0043] From the above description, it can be seen that the beneficial effects of the present invention are: a terminal of the present invention that enters an upgrade mode based on listening to Ethernet frames does not need to create a udp-socket at the application layer to listen to upgrade commands, but listens to the Ethernet frame before the Ethernet frame enters the TCP / IP protocol stack, and makes a judgment on the upgrade frame. If it is an upgrade frame, the application layer is notified to process it, which effectively avoids the memory usage caused by the udp-socket and saves memory resources.

[0044] Further, step S1 includes:

[0045] When the MAC driver receives the Ethernet frame transmitted from the physical layer, it determines whether the Ethernet frame is an upgrade frame.

[0046] From the above description, it can be seen that after the MAC layer receives the Ethernet frame transmitted by the PHY physical layer, it determines whether it is an upgrade frame, without the need to implement it through udp-socket.

[0047] Further, determining whether the Ethernet frame is an upgrade frame includes:

[0048] An identification code match is performed on the Ethernet frame. If the identification code of the Ethernet frame belongs to an upgrade frame identification code, the Ethernet frame is identified as an upgrade frame.

[0049] From the above description, it can be seen that the upgrade frame has a specific identification code. By matching the identification code, it is possible to determine whether it is an upgrade frame accurately and efficiently.

[0050] Further, the application layer is notified to obtain the upgrade firmware and enter the upgrade mode, including:

[0051] Parsing the upgrade frame to obtain the firmware acquisition address therein;

[0052] Notify the application layer to obtain the upgrade firmware through HTTPS according to the firmware acquisition address;

[0053] Reset to enter boot, and perform firmware upgrade according to the upgrade firmware.

[0054] It can be seen from the above description that after the upgrade frame is identified, the firmware acquisition address therein is parsed, the application layer is directly notified to acquire the upgrade firmware, and the upgrade is performed according to the acquired upgrade firmware.

[0055] Furthermore, the TCP / IP protocol stack adopts the LWIP protocol stack.

[0056] From the above description, we can see that the TCP / IP protocol stack chooses to use the LWIP protocol stack. While maintaining the core functions of TCP / IP, the LWIP protocol stack greatly reduces the occupancy of RAM and ROM, and has higher applicability for small embedded systems with limited resources.

[0057] The method and terminal of the present invention for entering an upgrade mode based on monitoring Ethernet frames are suitable for firmware upgrade of devices, especially for firmware upgrade of small embedded devices with limited resources.

[0058] Please refer to Figure 2 and Figure 3 , Embodiment 1 of the present invention is:

[0059] A method for entering an upgrade mode based on monitoring Ethernet frames, comprising the steps of:

[0060] S1. Before the TCP / IP protocol stack, monitor the Ethernet frame to determine whether the Ethernet frame is an upgrade frame;

[0061] Step S1 includes:

[0062] When the MAC driver receives the Ethernet frame transmitted from the physical layer, it determines whether the Ethernet frame is an upgrade frame.

[0063] In this embodiment, before the 802.3 Ethernet frame enters the TCP / IP protocol stack, an action of "listening for upgrade commands" is added to determine whether it is an upgrade frame. Figure 2 As shown, in this embodiment, after the MAC driver receives the Ethernet frame, it determines whether it is an upgrade frame.

[0064] Determining whether the Ethernet frame is an upgrade frame includes:

[0065] An identification code match is performed on the Ethernet frame. If the identification code of the Ethernet frame belongs to an upgrade frame identification code, the Ethernet frame is identified as an upgrade frame.

[0066] The format of the upgrade frame can be found in the following table:

[0067] Identification code 1 (4 Byte) Identification code 2 (4 Byte) URL string length (2Byte) URL(nByte) 0xA0A0A099 0xA0A0A099 n

[0068] In this embodiment, by matching identification code 1 and identification code 2, if identification code 1 and identification code 2 are both equal to 0xA0A0A099, it can be determined that the Ethernet frame is an upgrade frame.

[0069] S2. If the Ethernet frame is an upgrade frame, notify the application layer to obtain the upgrade firmware and enter the upgrade mode; otherwise, put the upgrade frame into the TCP / IP protocol stack;

[0070] Notify the application layer to obtain the upgrade firmware and enter the upgrade mode including:

[0071] Parsing the upgrade frame to obtain the firmware acquisition address therein;

[0072] Notify the application layer to obtain the upgrade firmware through HTTPS according to the firmware acquisition address;

[0073] Reset to enter boot, and perform firmware upgrade according to the upgrade firmware.

[0074] In this embodiment, refer to Figure 3 According to the judgment result of whether it is an upgrade frame, if the Ethernet frame is an upgrade frame, the frame is parsed to extract the URL, and the application layer is notified to initiate HTTPS to obtain the upgrade firmware from the PC. After the application layer obtains the upgrade firmware, it resets and enters the boot to upgrade the firmware.

[0075] If the Ethernet frame is not an upgrade frame, it is put into the TCP / IP protocol stack and processed as usual. In this embodiment, the TCP / IP protocol stack adopts the LWIP protocol stack.

[0076] Please refer to Figure 4 , Embodiment 2 of the present invention is:

[0077] A terminal 1 for entering an upgrade mode based on monitoring Ethernet frames comprises a processor 2, a memory 3, and a computer program stored in the memory 3 and executable on the processor 2. When the processor 2 executes the computer program, the steps of a method for entering an upgrade mode based on monitoring Ethernet frames in the first embodiment above are implemented.

[0078] To sum up, the present invention provides a method and terminal for entering an upgrade mode based on monitoring Ethernet frames. There is no need to create a udp-socket at the application layer to monitor upgrade commands. Instead, the Ethernet frame is monitored before entering the TCP / IP protocol stack, and the upgrade frame is judged. If it is an upgrade frame, the application layer is notified for processing, which effectively avoids the memory usage caused by the udp-socket and saves memory resources.

[0079] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for entering an upgrade mode based on monitoring Ethernet frames, characterized in that: Includes steps: S1. Before the TCP / IP protocol stack, monitor the Ethernet frame to determine whether the Ethernet frame is an upgrade frame; S2. If the Ethernet frame is an upgrade frame, the application layer is notified to obtain the upgrade firmware and enter the upgrade mode; otherwise, the upgrade frame is put into the TCP / IP protocol stack.

2. A method for entering an upgrade mode based on monitoring Ethernet frames according to claim 1, characterized in that: Step S1 includes: When the MAC driver receives the Ethernet frame transmitted from the physical layer, it determines whether the Ethernet frame is an upgrade frame.

3. A method for entering an upgrade mode based on monitoring Ethernet frames according to claim 1 or 2, characterized in that: Determining whether the Ethernet frame is an upgrade frame includes: An identification code match is performed on the Ethernet frame. If the identification code of the Ethernet frame belongs to an upgrade frame identification code, the Ethernet frame is identified as an upgrade frame.

4. The method for entering upgrade mode based on monitoring Ethernet frames according to claim 1, characterized in that: Notify the application layer to obtain the upgrade firmware and enter the upgrade mode including: Parsing the upgrade frame to obtain the firmware acquisition address therein; Notify the application layer to obtain the upgrade firmware through HTTPS according to the firmware acquisition address; Reset to enter boot, and perform firmware upgrade according to the upgrade firmware.

5. The method for entering an upgrade mode based on monitoring Ethernet frames according to claim 1, characterized in that: The TCP / IP protocol stack adopts the LWIP protocol stack.

6. A terminal that enters an upgrade mode based on monitoring Ethernet frames, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the following steps are implemented: S1. Before the TCP / IP protocol stack, monitor the Ethernet frame to determine whether the Ethernet frame is an upgrade frame; S2. If the Ethernet frame is an upgrade frame, the application layer is notified to obtain the upgrade firmware and enter the upgrade mode; otherwise, the upgrade frame is put into the TCP / IP protocol stack.

7. A terminal for entering an upgrade mode based on monitoring Ethernet frames according to claim 6, characterized in that: Step S1 includes: When the MAC driver receives the Ethernet frame transmitted from the physical layer, it determines whether the Ethernet frame is an upgrade frame.

8. A terminal for entering an upgrade mode based on monitoring Ethernet frames according to claim 6 or 7, characterized in that: Determining whether the Ethernet frame is an upgrade frame includes: An identification code match is performed on the Ethernet frame. If the identification code of the Ethernet frame belongs to an upgrade frame identification code, the Ethernet frame is identified as an upgrade frame.

9. A terminal for entering an upgrade mode based on monitoring Ethernet frames according to claim 6, characterized in that: Notify the application layer to obtain the upgrade firmware and enter the upgrade mode including: Parsing the upgrade frame to obtain the firmware acquisition address therein; Notify the application layer to obtain the upgrade firmware through HTTPS according to the firmware acquisition address; Reset to enter boot, and perform firmware upgrade according to the upgrade firmware.

10. A terminal for entering an upgrade mode based on monitoring Ethernet frames according to claim 6, characterized in that: The TCP / IP protocol stack adopts the LWIP protocol stack.