Remote single-chip microcomputer upgrading method and system

By connecting the SWD programming pin of the USB connector to the microcontroller, and combining Linux cross-compilation with the remote upgrade method of the SWD programming pin, the problem of traditional microcontroller upgrade methods requiring disassembly and on-site connection is solved, realizing remote upgrade and online diagnosis, and reducing cost and time overhead.

CN121680923APending Publication Date: 2026-03-17HUARUAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511860043.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-10
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Traditional microcontroller upgrade methods require disassembling the device or connecting a dedicated emulator on-site, which is costly and inefficient. Remote compilation and distribution are not possible, and STM and ARTERYTEK series microcontrollers do not have USB ports available as mass production programming channels.

Method used

By connecting the MCU's SWD programming pin to the same USB connector, an upgrade-debugging multiplexed channel is formed. The official flash function is modified using a Linux cross-compiler, and the agent program is written using the SWD programming pin. The J-Link device on the computer decrypts the USB and completes the upgrade data transmission. After the writing is completed, the old firmware is automatically rolled back for remote online debugging.

Benefits of technology

It enables remote microcontroller upgrades, saving travel costs, and supports online program modification and remote diagnostics, reducing hardware modifications and time costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121680923A_ABST
    Figure CN121680923A_ABST
Patent Text Reader

Abstract

The invention discloses a remote single-chip microcomputer upgrading method and system. The method comprises the steps that firstly, SWD burning pins of an MCU are connected into the same USB connector to form an upgrading-debugging multiplexing channel, then, an arm-non-eabi-gcc compiler is utilized to modify and compile an official flash function, an agent program is written into the MCU through the SWD burning pins, a computer end solves Jlink equipment of a USB to complete upgrading data issuing, and finally, after writing is completed, an agent returns a verification result and resets the MCU, and the upgrading-debugging multiplexing channel is formed. If the old firmware fails, the old firmware is automatically rolled back from the backup area, meanwhile, an SWD channel is opened for remote online debugging, the cost of business trip to the scene can be saved through remote upgrading and simulation of the single chip microcomputer, and program modification in various environments can be dealt with.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of embedded microcontroller technology, and in particular to a remote microcontroller upgrade method and system. Background Technology

[0002] With the widespread application of embedded microcontrollers in industrial, home appliance, and energy sectors, the need for program iteration after device deployment is becoming increasingly frequent.

[0003] Traditional upgrade methods require disassembling the device or connecting a dedicated emulator on-site, resulting in high travel costs, low efficiency, and difficulty in handling unexpected defects. Although STMicroelectronics (STM) and Artery Microcontrollers have built-in bootstrap programs, the manufacturers only open serial ports such as UART / CAN for upgrades, and do not directly open USB ports as mass production programming channels. At the same time, the official Flash operation functions are based on the IDE graphical interface, which cannot be directly ported to the embedded Linux platform for remote compilation and distribution.

[0004] Therefore, how to complete remote upgrades and online simulations with minimal hardware modifications and using universal USB pins has become a pressing technical problem to be solved in this field. Summary of the Invention

[0005] Based on this, this application provides a remote microcontroller upgrade method and system. Remote upgrade and simulation of the microcontroller can save the cost of traveling to the site and is conducive to dealing with program modifications in various environments, thereby solving the problems existing in the prior art.

[0006] Firstly, a method for remotely upgrading a microcontroller is provided, the method comprising:

[0007] Hardware channel establishment: Connect the MCU's SWD programming pins to the same USB connector to form an upgrade-debugging multiplexed channel;

[0008] Linux cross-compilation: The software is developed in a Linux environment using the arm-none-eabi-gcc compiler, and the official flash functions are modified and compiled.

[0009] Upgrade Agent Injection: The agent program is written into the MCU via the SWD programming pin;

[0010] Image download: The J-Link device connected to the computer via USB completes the upgrade data download;

[0011] Result Confirmation and Rollback: After the write operation is completed, the agent returns the verification result and resets the MCU. If it fails, it automatically rolls back the old firmware from the backup area and opens the SWD channel for remote online debugging.

[0012] Optionally, the Linux cross-compilation specifically includes: deploying arm-none-eabi-gcc on a remote Linux host, de-IDEning the official Flash operation functions and encapsulating CRC verification, and generating an upgrade agent program.

[0013] Optionally, the proxy injection specifically includes:

[0014] The upgrade agent is written to the MCU boot area and the startup item is configured via the SWD channel, so that the agent runs first after the MCU is powered on.

[0015] Optionally, the image distribution specifically includes:

[0016] The remote host will send the upgraded image in packets via a USB virtual serial port. After the agent completes the full packet verification in RAM, it will call the trimmed Flash interface to erase and write the data to the application area.

[0017] Optionally, the SWD channel can be opened for remote online debugging, including:

[0018] The remote host connects to the MCU via OpenOCD through the USB-SWD multiplexed channel and uses arm-none-eabi-gdb for breakpoints, single-stepping, and register viewing to enable remote diagnosis after an upgrade failure.

[0019] Secondly, a remote microcontroller upgrade system is provided, the system comprising:

[0020] The hardware channel establishment module is used to connect the MCU's SWD programming pins to the same USB connector to form an upgrade-debugging multiplexed channel;

[0021] The Linux cross-compilation module is used for development in a Linux environment, using the arm-none-eabi-gcc compiler to modify and compile official flash functions;

[0022] Upgrade the agent injection module to write the agent program into the MCU via the SWD programming pin;

[0023] The image distribution module is used by the computer to decrypt the USB J-Link device and complete the upgrade data distribution.

[0024] The result confirmation and rollback module is used to return the verification result and reset the MCU after the write is completed. If it fails, it will automatically roll back the old firmware from the backup area. At the same time, it opens the SWD channel for remote online debugging.

[0025] Thirdly, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the remote microcontroller upgrade method described in any of the first aspects above.

[0026] Fourthly, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the remote microcontroller upgrade method described in any of the first aspects above.

[0027] Fifthly, a computer program product is provided, including a computer program / instruction that, when executed by a processor, implements the remote microcontroller upgrade method described in any of the first aspects above.

[0028] In this application, the MCU's SWD programming pin is first connected to the same USB connector, forming an upgrade-debugging multiplexed channel. Then, using the arm-none-eabi-gcc compiler, the official flash functions are modified and compiled, and the proxy program is written to the MCU via the SWD programming pin. The J-Link device on the computer decodes the USB to complete the upgrade data transmission. Finally, after the writing is completed, the proxy returns the verification result and resets the MCU. If it fails, it automatically rolls back the old firmware from the backup area, and simultaneously opens the SWD channel for remote online debugging. It can be seen that the technical solution provided by this application has at least the following benefits: it can save the cost of traveling to the site and facilitate program modifications in various environments. Attached Figure Description

[0029] To more clearly illustrate the embodiments of this application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are merely exemplary, and those skilled in the art can derive other embodiments based on the provided drawings without creative effort.

[0030] Figure 1 A flowchart illustrating the steps of a remote microcontroller upgrade method provided in this application embodiment;

[0031] Figure 2 The circuit schematic provided for the embodiments of this application;

[0032] Figure 3 This application provides a PCB pin assignment diagram for an embodiment of the invention.

[0033] Figure 4 This is a schematic diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0034] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0035] In the description of this application, the terms "comprising," "having," and any variations thereof are intended to cover non-exclusive inclusion, such as a process, method, system, product, or apparatus that includes a series of steps or units, not necessarily limited to those steps or units that are expressly listed, but may also include other steps or units that are not expressly listed but are inherent to these processes, methods, products, or apparatuses, or steps or units added based on further optimizations conceived in this application.

[0036] Please refer to Figure 1 The diagram illustrates a flowchart of a remote microcontroller upgrade method provided in an embodiment of this application. The method may include the following steps:

[0037] Hardware channel establishment: Connect the MCU's SWD programming pins to the same USB connector to form an upgrade-debugging multiplex channel.

[0038] The USB pins are used only for monitoring upgrade data and are not used for programming.

[0039] Linux cross-compilation: The software is developed in a Linux environment using the arm-none-eabi-gcc compiler, and the official flash functions are modified and compiled.

[0040] Upgrade Agent Injection: The agent program is written into the MCU via the SWD programming pin.

[0041] Image download: The J-Link device connected to the computer via USB completes the upgrade data download.

[0042] Result Confirmation and Rollback: After the write operation is completed, the agent returns the verification result and resets the MCU. If it fails, it automatically rolls back the old firmware from the backup area and opens the SWD channel for remote online debugging.

[0043] In the embodiments of this application, such as Figure 2 The circuit schematic is provided. Figure 3 The PCB pin assignment diagram, in this embodiment using the STM32F103 microcontroller as an example, is as follows:

[0044] 1. Hardware channel establishment

[0045] In practice, only pins 17 and 18 are led to the differential data lines of the USB connector for data monitoring during the upgrade process; the actual programming and debugging are still completed by SWDCLK / SWDIO corresponding to pins 19 and 20. The two signal lines are also led to the idle pins of the USB connector, forming a multiplexed structure of "USB only for monitoring, programming by SWD".

[0046] 2. Linux cross-compilation

[0047] The software is developed in a Linux environment using the arm-none-eabi-gcc compiler. It modifies and compiles the official flash functions, and completes the modification and compilation of the official flash functions on a remote Linux host to generate the upgrade agent program.

[0048] 3. Upgrade proxy injection

[0049] The proxy program is written to the MCU through the SWD programming pin. The proxy program generated in the previous step is burned into the microcontroller using the programming channels corresponding to pins 19 and 20. No further disassembly is required.

[0050] 4. Image distribution

[0051] The host connects to these two USB pins ( Figure 2 The upgrade data (pins 19 and 20) is sent to the single board to complete the remote transmission.

[0052] 5. Result Confirmation and Rollback

[0053] The agent program returns the result and resets the MCU after writing; if it fails, it automatically rolls back the old firmware from the backup area while keeping the programming pins on the same connector open for remote online debugging.

[0054] Another optional embodiment of this application is given below:

[0055] The first step is to fabricate the PCB board and mount the components.

[0056] Components: Purchase microprocessors, resistors, inductors, capacitors, relays, connectors, etc. from reliable component manufacturers based on the PCB's BOM.

[0057] Circuit board: Manufactured by a professional circuit board manufacturer. Send the Gerber files to the PCBA manufacturer, along with the purchased components, for SMT assembly.

[0058] Specific steps:

[0059] Drawing the schematic diagram.

[0060] PCB design.

[0061] PCB manufacturing is outsourced to external manufacturers.

[0062] SMT assembly is performed on the PCB board.

[0063] test.

[0064] Finalization.

[0065] Once the circuit board is working properly, it can be connected to the remote control of a smart device.

[0066] This application also provides a remote microcontroller upgrade system, which may include:

[0067] The hardware channel establishment module is used to connect the MCU's SWD programming pins to the same USB connector to form an upgrade-debugging multiplexed channel;

[0068] The Linux cross-compilation module is used for development in a Linux environment, using the arm-none-eabi-gcc compiler to modify and compile official flash functions;

[0069] Upgrade the agent injection module to write the agent program into the MCU via the SWD programming pin;

[0070] The image distribution module is used by the computer to decrypt the USB J-Link device and complete the upgrade data distribution.

[0071] The result confirmation and rollback module is used to return the verification result and reset the MCU after the write is completed. If it fails, it will automatically roll back the old firmware from the backup area. At the same time, it opens the SWD channel for remote online debugging.

[0072] For specific limitations regarding the remote microcontroller upgrade system, please refer to the limitations of the remote microcontroller upgrade method described above, which will not be repeated here. Each module in the aforementioned remote microcontroller upgrade system can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of the computer device in hardware form or independent of it, or they can be stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each module.

[0073] In one embodiment, an electronic device is provided, which may be a computer, and its internal structure diagram may be as follows: Figure 4 As shown, the electronic device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The database of the computer device is used for remote microcontroller upgrade data. The network interface of the computer device is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a remote microcontroller upgrade method.

[0074] Those skilled in the art will understand that, Figure 4The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0075] In one embodiment of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the above-described remote microcontroller upgrade method.

[0076] In one embodiment of this application, a computer program product is provided, including a computer program / instructions, which, when executed by a processor, implements the steps of the above-described remote microcontroller upgrade method.

[0077] The computer-readable storage medium and computer program product provided in this embodiment are similar in implementation principle and technical effect to the above method embodiments, and will not be repeated here.

[0078] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. 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 methods.

[0079] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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.

[0080] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A method for remotely upgrading a microcontroller, characterized in that, The method includes: Hardware channel establishment: Connect the MCU's SWD programming pins to the same USB connector to form an upgrade-debugging multiplexed channel; Linux cross-compilation: The software is developed in a Linux environment using the arm-none-eabi-gcc compiler, and the official flash functions are modified and compiled. Upgrade Agent Injection: The agent program is written into the MCU via the SWD programming pin; Image download: The J-Link device connected to the computer via USB completes the upgrade data download; Result Confirmation and Rollback: After the write operation is completed, the agent returns the verification result and resets the MCU. If it fails, it automatically rolls back the old firmware from the backup area and opens the SWD channel for remote online debugging.

2. The remote microcontroller upgrade method according to claim 1, characterized in that, The Linux cross-compilation specifically includes: deploying arm-none-eabi-gcc on a remote Linux host, de-IDEning the official Flash operation functions and encapsulating CRC verification, and generating an upgrade agent program.

3. The remote microcontroller upgrade method according to claim 1, characterized in that, The proxy injection specifically includes: The upgrade agent is written to the MCU boot area and the startup item is configured via the SWD channel, so that the agent runs first after the MCU is powered on.

4. The remote microcontroller upgrade method according to claim 1, characterized in that, The image distribution specifically includes: The remote host will send the upgraded image in packets via a USB virtual serial port. After the agent completes the full packet verification in RAM, it will call the trimmed Flash interface to erase and write the data to the application area.

5. The remote microcontroller upgrade method according to claim 1, characterized in that, Open the SWD channel for remote online debugging, including: The remote host connects to the MCU via OpenOCD through the USB-SWD multiplexed channel and uses arm-none-eabi-gdb for breakpoints, single-stepping, and register viewing to enable remote diagnosis after an upgrade failure.

6. A remote microcontroller upgrade system, characterized in that, The system includes: The hardware channel establishment module is used to connect the MCU's SWD programming pins to the same USB connector to form an upgrade-debugging multiplexed channel; The Linux cross-compilation module is used for development in a Linux environment, using the arm-none-eabi-gcc compiler to modify and compile official flash functions; Upgrade the agent injection module to write the agent program into the MCU via the SWD programming pin; The image distribution module is used by the computer to decrypt the USB J-Link device and complete the upgrade data distribution. The result confirmation and rollback module is used to return the verification result and reset the MCU after the write is completed. If it fails, it will automatically roll back the old firmware from the backup area. At the same time, it opens the SWD channel for remote online debugging.

7. An electronic device, characterized in that, It includes a memory and a processor, wherein the memory stores a computer program, and the computer program, when executed by the processor, implements the remote microcontroller upgrade method as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, It stores a computer program, which, when executed by a processor, implements the remote microcontroller upgrade method as described in any one of claims 1 to 5.

9. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instruction is executed by the processor, it implements the remote microcontroller upgrade method according to any one of claims 1 to 5.