A programming device and method for an in-vehicle MCU
Patent Information
- Application Number
- CN202611344637.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-01
- Publication Date
- 2026-10-30
AI Technical Summary
局限性1:传输效率固定且无法优化
1、效率的提升:本发明在四线模式下,理论上可比传统单线SWD模式提升4倍以上的原始比特率;加之绕过MCU内部总线进行编程,直接控制Flash,综合数据传输效率可实现数倍的提升,直接缩短编程时间。
Smart Images

Figure CN123011593A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automotive electronics and embedded systems technology, and in particular to a programming device and method for an in-vehicle MCU. Background Technology
[0002] Existing automotive MCU programming and communication solutions are mainly based on mature standardized protocols, but they have revealed the following key limitations in practical applications: Limitation 1: Fixed and unoptimizable transmission efficiency. Existing protocols (such as UART-based bootloader protocols, single-wire emulation SWD protocols, and standard SPI protocols) have their communication wiring (single-wire, two-wire, four-wire) and frame structure fixed during the hardware design phase. For example, if only a single-wire interface is used to reduce costs, the upper limit of the rate for all subsequent programming tasks is permanently locked at a low level, making it impossible to dynamically adjust efficiency based on different application scenarios (such as fast programming on the production line vs. slow diagnostics in after-sales service) or system resource usage.
[0003] Limitation 2: Lengthy protocols and low effective data load. Many standard or custom protocols contain numerous fixed control headers, fixed-length idle bits, and complex command-response handshake processes. When transmitting actual programmed data, protocol overhead accounts for a high percentage, with a large amount of bandwidth used to transmit non-data content, resulting in low effective throughput.
[0004] Limitation 3: Data integrity protection mechanisms are singular or insufficient. Common solutions either rely solely on the inherent stability of the hardware interface or use simple checksums. The former lacks reliability in the complex electromagnetic environment of an in-vehicle vehicle; the latter has weak error detection capabilities, failing to detect multi-bit errors or specific error patterns, posing a risk of silent corruption of programmed data and affecting the reliability of the final firmware. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention presents a comprehensive solution centered on a dynamically configurable multi-wire data transmission protocol. It deeply integrates a dynamically configurable 1 / 2 / 4-wire physical layer, a streamlined and efficient custom frame structure protocol, and a robust CRC check mechanism throughout, forming a complete, adaptive, highly efficient, and reliable programming communication stack. This solution is reflected in both the host programmer's software logic and embedded in the target MCU programming control module; the two work together to achieve end-to-end optimization from physical connection to application layer data.
[0006] To achieve the above objectives, the present invention provides a programming device for an in-vehicle MCU, comprising: a programmer host and a programming control module on the target MCU; the programmer host and the target MCU are connected via a set of physical interfaces with dynamically configurable communication lines; The programmer host includes: The multi-line communication interface module is used to adaptively switch between multiple transmission line systems according to preset strategies or test results. The programming control module on the target MCU includes: The protocol parsing and encapsulation module is used to parse instructions and data from the programmer host according to a custom simplified communication protocol, and to encapsulate data sent to the programmer host; the frame structure of the custom simplified communication protocol includes a fixed header, a simplified protocol command, a data field, and a strong check bit; The error verification and processing module includes at least a cyclic redundancy check unit, which is used to perform real-time verification of transmitted data at the data link layer of the protocol stack and to perform end-to-end data integrity verification at the application layer.
[0007] Furthermore, the various transmission line systems include at least single-wire, two-wire, and four-wire communication modes.
[0008] Furthermore, the multi-wire communication interface module also includes a pre-test unit, which is used to pre-send test data to the target MCU during the programming session initialization phase, and select the optimal wired communication mode from single-wire, dual-wire, or four-wire communication modes based on the calculated communication transmission error rate.
[0009] Furthermore, the error verification and processing module also includes a forward error correction unit, which is used to activate the error correction coding function in conjunction with the cyclic redundancy check unit when the bit error rate is detected to exceed a preset threshold, so as to automatically correct bit errors in the transmission process.
[0010] Furthermore, the simplified protocol command includes the data length and data type information of this transmission, and the data type information includes address, data, and command.
[0011] Furthermore, the command supports a fast programming command. After the programmer host sends the fast programming command, it will continuously send data streams without repeatedly including address information in each frame of data. The target MCU automatically increments the programming address pointer to receive the data stream.
[0012] Furthermore, the programming control module also includes an asynchronous transmit FIFO connected to the protocol parsing and encapsulation module, used to temporarily store and forward parsed commands and data to the Flash memory operation logic; and a receive FIFO, used to temporarily store data read from the Flash memory and prepared to be sent to the programmer host.
[0013] The present invention also provides a programming method for an automotive MCU, based on the above-described programming device for an automotive MCU, comprising the following steps: (1) Based on the preset strategy or test results, the programmer host adaptively selects the transmission line system between itself and the target MCU; (2) Encapsulate the control commands or programming data to be transmitted into a custom simplified communication protocol frame containing a fixed header, simplified protocol commands, data fields and strong check bits, and calculate the check code for the entire frame content; (3) The programmer host sends the custom simplified communication protocol frame according to the selected transmission line system, and the target MCU verifies the received frame through the protocol parsing and encapsulation module; (4) If the verification passes, the target MCU executes the corresponding Flash memory operation according to the protocol command, bypassing the target MCU's internal bus to interact directly with the Flash memory; if the verification fails, the request is ignored and the error status is updated. (5) Repeat steps (2)-(4) until the programming is complete.
[0014] Furthermore, when the programmer host sends a command to read the Flash memory, after the Flash has prepared the data, the target MCU encapsulates the data into a custom simplified communication protocol frame containing a fixed header, simplified protocol command, data field and strong check bit through the protocol parsing and encapsulation module, calculates the check code for the entire frame content, and sends the data to be sent to the programmer host according to the selected transmission line system.
[0015] Furthermore, the test results are as follows: during the programming session initialization phase, the programmer host pre-sends test data to the target MCU, and selects the optimal wired communication mode from single-wire, dual-wire, or quad-wire communication modes based on the calculated communication transmission error rate.
[0016] The beneficial effects of this invention are: 1. Improved efficiency: In four-wire mode, this invention can theoretically improve the raw bit rate by more than 4 times compared to the traditional single-wire SWD mode; in addition, by bypassing the internal bus of the MCU for programming and directly controlling the Flash, the overall data transmission efficiency can be improved by several times, directly shortening the programming time.
[0017] 2. Enhanced flexibility: The adaptive line switching of this invention enables the same set of hardware and underlying software to seamlessly adapt to all scenarios from low-speed after-sales diagnostics to high-speed production line programming, without the need to develop different hardware variants or firmware branches for different scenarios, thus reducing development and maintenance complexity.
[0018] 3. Improved Reliability: The strong CRC checksum of this invention reduces the probability of undetectable data errors to an extremely low level. This ensures that errors are detected and corrected promptly during transmission, greatly improving the first-time success rate of programming and the correctness of the final firmware. ECC can be enabled in harsh environments to increase real-time ECC error correction capabilities, forming a three-layer protection system of "detection-correction-verification". Attached Figure Description
[0019] Figure 1 This is a schematic diagram of the programming device for an in-vehicle MCU according to an embodiment of the present invention.
[0020] Figure 2 This is a schematic diagram of the programming method for an in-vehicle MCU according to an embodiment of the present invention.
[0021] Figure 3 This is a schematic diagram of the programming method for an in-vehicle MCU according to an embodiment of the present invention (when the quick programming command is started). Detailed Implementation
[0022] The present invention will be further explained and described below with reference to the accompanying drawings and embodiments.
[0023] like Figure 1 As shown, this embodiment of the invention provides a programming device for an automotive MCU, suitable for scenarios where data programming and firmware updates of the Flash memory of an automotive MCU are performed via a dedicated programmer or OTA upgrade channel. This programming device deeply integrates a dynamically configurable 1 / 2 / 4-wire physical layer, a streamlined and efficient custom frame structure protocol, and a consistently strong CRC check mechanism, forming a complete, adaptive, efficient, and reliable programming communication stack. This stack is reflected in the software logic of the host programmer and embedded in the target MCU programming control module, with both working together to achieve end-to-end optimization from physical connection to application layer data.
[0024] The programming device includes: a programmer host and a programming control module on the target MCU; the programmer host and the target MCU are connected through a set of physical interfaces with dynamically configurable communication lines.
[0025] The programmer host includes: The multi-line communication interface module is used to adaptively switch between single-line, dual-line, or four-line communication modes based on preset strategies or test results.
[0026] The multi-wire communication interface module also includes a pre-test unit, used to pre-send test data to the target MCU during the programming session initialization phase, and select the optimal wired communication mode from single-wire, dual-wire, or quad-wire communication modes based on the calculated communication transmission error rate. For example, in scenarios requiring high speed, the quad-wire data mode can be enabled, significantly improving programming speed.
[0027] Single-wire mode: Used for reliable connections in environments with extremely limited pin resources or long distances and high interference.
[0028] Dual-line mode: Based on single-line mode, it improves programming speed and efficiency, balancing speed and reliability.
[0029] Four-wire mode: Used for scenarios with extreme speed requirements to achieve high-speed data transmission.
[0030] The programming control module on the target MCU includes: The protocol parsing and encapsulation module is used to parse instructions and data from the programmer host according to a custom simplified communication protocol, and to encapsulate the data sent to the programmer host. The frame structure of the custom simplified communication protocol includes a fixed header, simplified protocol commands, data fields, and strong check bits.
[0031] The simplified protocol commands in the custom simplified communication protocol include the data length and data type information for this transmission, and support quick programming commands. When executing quick programming commands, the programmer host can continuously send data streams, and the target MCU automatically increments the programming address pointer internally, without needing to repeatedly include address information in each frame of data. Data type information includes address and plain data.
[0032] The protocol frame abandons complex nested structures, adopting a minimalist design of "fixed header + simplified protocol command + data + strong checksum". The simplified protocol command explicitly contains the data length and data type information for this transmission, including address, data, and command. The command supports fast programming commands. After the programmer host sends a fast programming command, it enters "fast programming" mode, and subsequently sends data streams continuously without repeating address information in each data frame; the target MCU automatically increments the programming address pointer to receive the data stream, greatly reducing protocol interruptions.
[0033] The error verification and processing module includes at least a cyclic redundancy check unit, which is used to perform real-time verification of transmitted data at the data link layer of the protocol stack and to perform end-to-end data integrity verification at the application layer.
[0034] The error verification and processing module may also include a forward error correction unit, which, when the bit error rate exceeds a preset threshold, activates an error correction coding function that works in conjunction with the cyclic redundancy check unit to automatically correct bit errors during transmission. For scenarios with higher reliability requirements, it can be configured for single-line transmission mode, and data transmission accuracy is ensured through ECC encoding and strong CRC checksum.
[0035] The programming control module also includes an asynchronous transmit FIFO connected to the protocol parsing and encapsulation module, used to temporarily store and forward parsed commands and data to the Flash memory operation logic; and a receive FIFO, used to temporarily store data read from the Flash memory and prepared to be sent to the programmer host. The programming control module programs the Flash memory directly by manipulating the Flash address without using the internal bus, and performs erase / programming operations according to protocol commands.
[0036] The programming device for vehicle MCU proposed in this invention effectively solves the contradiction between efficiency and reliability in traditional solutions, comprehensively improving the throughput, success rate and environmental adaptability of vehicle MCU programming, and has significant practical value.
[0037] like Figure 2 As shown, this embodiment of the invention also provides a programming method for an in-vehicle MCU, including the following steps: S101. Based on a preset strategy or test results, the programmer host adaptively selects the transmission line system between itself and the target MCU.
[0038] The test results come from the fact that during the programming session initialization phase, the programmer host pre-sends test data to the target MCU and selects the optimal wired communication mode from single-wire, dual-wire, or quad-wire communication modes based on the calculated communication transmission error rate.
[0039] S102. Encapsulate the control commands or programming data to be transmitted into a custom simplified communication protocol frame containing a fixed header, simplified protocol commands, data fields and strong check bits, and calculate the check code for the entire frame content.
[0040] S103. The programmer host sends the custom simplified communication protocol frame according to the selected transmission line system, and the target MCU verifies the received frame through the protocol parsing and encapsulation module.
[0041] S104. If the verification passes, the target MCU executes the corresponding Flash memory operation according to the protocol command, bypassing the target MCU's internal bus to interact directly with the Flash memory; if the verification fails, the request is ignored and the error status is updated.
[0042] S105. Repeat steps S102-S104 until programming is complete.
[0043] In addition, when the programmer host sends a command to read the Flash memory, after the Flash prepares the data, the target MCU encapsulates the data into a custom simplified communication protocol frame containing a fixed header, simplified protocol command, data field and strong check bit through the protocol parsing and encapsulation module, calculates the check code for the entire frame content, and sends the data to be sent to the programmer host according to the selected transmission line system.
[0044] Example 1: Terminal programming for automobile production lines.
[0045] Scenario: On the vehicle assembly line, the initial software of the vehicle gateway MCU needs to be programmed using probes at the test station, with stringent time requirements.
[0046] Implementation: The industrial control computer (host) is connected to the MCU via a four-wire interface and configured for four-wire transmission mode.
[0047] The programming data is sent continuously using the "quick programming command" in the custom protocol.
[0048] Each programming data frame includes a CRC check result.
[0049] Results: Compared with traditional single-line diagnostic protocols, programming time is significantly reduced, meeting production line cycle time requirements, and CRC check ensures 100% accuracy of programmed data even in factory environments with high electrical noise.
[0050] The specific process of this embodiment is as follows: Figure 3 As shown, to improve programming efficiency, it can be configured to a 4-line data mode. Configure the starting programming address, and then send a fast programming command. Send the data required for a single fast programming operation according to actual needs. After the data meets the requirements, the programming operation is automatically initiated, and the address is automatically incremented to continue programming the next address.
[0051] Example 2: 4S store after-sales system software update. Scenario: A vehicle is returned to the shop due to a software issue, requiring a partial update of the vehicle's MCU (Microcontroller Unit) via an OBD diagnostic port connection to a laptop. The vehicle's power supply may be unstable, and environmental interference is unknown.
[0052] Implementation: The diagnostic software starts and attempts to communicate with the MCU via a single data line in the diagnostic connector. Although slow, the protocol is streamlined and has a high payload capacity.
[0053] During transmission, CRC checks on each frame ensure correct data reception even with long connection lines and potential interference. Even if a frame fails due to voltage fluctuations, it will not trigger erroneous operations on the Flash memory, preventing significant impact.
[0054] Results: Without increasing vehicle hardware costs or interface complexity, the existing single-wire interface was used to achieve update reliability and acceptable update speed far exceeding traditional solutions, ensuring the success rate of after-sales maintenance and customer satisfaction.
[0055] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A programming device for an in-vehicle MCU, characterized in that, include: The programming control module on the programmer host and the target MCU; The programmer host and the target MCU are connected via a set of physical interfaces with dynamically configurable communication lines; The programmer host includes: The multi-line communication interface module is used to adaptively switch between multiple transmission line systems according to preset strategies or test results. The programming control module on the target MCU includes: The protocol parsing and encapsulation module is used to parse instructions and data from the programmer host according to a custom simplified communication protocol, and to encapsulate data sent to the programmer host; the frame structure of the custom simplified communication protocol includes a fixed header, a simplified protocol command, a data field, and a strong check bit; The error verification and processing module includes at least a cyclic redundancy check unit, which is used to perform real-time verification of transmitted data at the data link layer of the protocol stack and to perform end-to-end data integrity verification at the application layer.
2. The programming device for an in-vehicle MCU according to claim 1, characterized in that: The various transmission line systems include at least single-wire, two-wire, and four-wire communication modes.
3. The programming device for an in-vehicle MCU according to claim 2, characterized in that: The multi-wire communication interface module also includes a pre-test unit, which is used to pre-send test data to the target MCU during the programming session initialization phase, and select the optimal wired communication mode from single-wire, dual-wire, or four-wire communication modes based on the calculated communication transmission error rate.
4. The programming device for an in-vehicle MCU according to claim 1, characterized in that: The error verification and processing module also includes a forward error correction unit, which is used to activate the error correction coding function in conjunction with the cyclic redundancy check unit when the bit error rate is detected to exceed a preset threshold, so as to automatically correct bit errors during transmission.
5. The programming device for an in-vehicle MCU according to claim 1, characterized in that: The simplified protocol command includes the data length and data type information of this transmission, and the data type information includes address, data, and command.
6. The programming device for an in-vehicle MCU according to claim 5, characterized in that: The command supports fast programming commands. After the programmer host sends a fast programming command, it will continuously send data streams without repeating address information in each frame of data. The target MCU automatically increments the programming address pointer to receive the data stream.
7. The programming device for an in-vehicle MCU according to claim 1, characterized in that: The programming control module also includes an asynchronous transmit FIFO connected to the protocol parsing and encapsulation module, used to temporarily store and forward parsed commands and data to the Flash memory operation logic; and a receive FIFO, used to temporarily store data read from the Flash memory and prepared to be sent to the programmer host.
8. A programming method for an automotive MCU, based on the programming apparatus for an automotive MCU according to any one of claims 1-7, characterized in that, Includes the following steps: (1) Based on the preset strategy or test results, the programmer host adaptively selects the transmission line system between itself and the target MCU; (2) Encapsulate the control commands or programming data to be transmitted into a custom simplified communication protocol frame containing a fixed header, simplified protocol commands, data fields and strong check bits, and calculate the check code for the entire frame content; (3) The programmer host sends the custom simplified communication protocol frame according to the selected transmission line system, and the target MCU verifies the received frame through the protocol parsing and encapsulation module; (4) If the verification passes, the target MCU executes the corresponding Flash memory operation according to the protocol command, bypassing the target MCU's internal bus and interacting directly with the Flash memory; If the verification fails, ignore this request and update the error status; (5) Repeat steps (2)-(4) until the programming is complete.
9. The programming method for an in-vehicle MCU according to claim 8, characterized in that: When the programmer host sends a command to read the Flash memory, after the Flash prepares the data, the target MCU encapsulates the data into a custom simplified communication protocol frame containing a fixed header, simplified protocol command, data field and strong check bit through the protocol parsing and encapsulation module, calculates the check code for the entire frame content, and sends the data to be sent to the programmer host according to the selected transmission line system.
10. The programming method for an in-vehicle MCU according to claim 8, characterized in that, The test results are as follows: During the programming session initialization phase, the programmer host pre-sends test data to the target MCU and selects the optimal wired communication mode from single-wire, dual-wire, or quad-wire communication modes based on the calculated communication transmission error rate.
