Firmware flashing method, device and system of vehicle-mounted ECU (Electronic Control Unit) and electronic equipment
By dynamically adjusting the communication rate of the vehicle ECU and using a DMA controller and dual-bank storage structure, the problems of data loss and increased time caused by high baud rates in vehicle ECU firmware flashing are solved, achieving an efficient and stable firmware flashing process.
Patent Information
- Application Number
- CN202511390870.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-26
- Publication Date
- 2025-12-19
AI Technical Summary
During the firmware flashing process of vehicle ECUs, existing technologies, in pursuit of high baud rates, are prone to data frame reception errors, leading to interruptions in the flashing process or the need for multiple retransmissions, increasing the overall flashing time and reducing the effective data throughput.
By acquiring the current channel status of the vehicle communication bus, the system dynamically switches to the appropriate target communication rate, receives firmware data based on the target communication rate, and completes the flashing process in the memory. Combined with a DMA controller and a dual-bank storage structure, efficient data transfer and verification are achieved.
It significantly improves the stability and effective throughput of the writing process, avoids the waste of bandwidth resources and data loss caused by blindly transmitting at high speed under poor channels, shortens the writing time and improves robustness.
Smart Images

Figure CN121166176A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of firmware flashing technology, and more specifically, to a method, apparatus, system, and electronic device for flashing firmware for an automotive ECU. Background Technology
[0002] With the development of intelligent and connected vehicles, the number of ECUs (Electronic Control Units) is increasing, and the complexity of software is rising, leading to frequent needs for firmware flashing (such as OTA (Over-The-Air) upgrades, diagnostics, and maintenance). The transmission efficiency and reliability of these firmware flashing processes directly affect the success rate and user experience.
[0003] In the traditional process of flashing vehicle ECU firmware, in order to shorten the flashing time and improve the user experience, it is common to increase the physical layer communication rate as the main means to achieve high-speed data transmission.
[0004] However, this strategy of solely pursuing high baud rates has serious drawbacks in real-world automotive environments. For example, under certain conditions, even if the communication physical layer is configured at a high baud rate, problems such as data frame reception errors may still occur, leading to interruptions in the flashing process or the need for multiple retransmissions. This actually increases the overall flashing time and consequently causes a significant decrease in the actual effective data throughput. Summary of the Invention
[0005] In view of this, the purpose of the present invention is to provide a method, apparatus, system and electronic device for flashing firmware of an in-vehicle ECU, so as to improve the effective throughput during the firmware flashing process of the in-vehicle ECU.
[0006] Firstly, a method for flashing firmware for an on-board ECU is provided, including: In response to a flash request sent by a diagnostic device, obtain the current channel status of the vehicle communication bus; Dynamically switch to the appropriate target communication rate based on the current channel status; Receive firmware data from diagnostic devices based on the target communication rate; The received firmware data is written to the memory to complete the firmware flashing process.
[0007] Optionally, dynamically switching to the appropriate target communication rate based on the current channel state includes: The current channel quality level of the vehicle communication bus is determined based on the aforementioned channel state; the parameters characterizing the channel state include at least the bit error rate. Based on the current channel quality level and the preset correspondence between channel quality level and communication rate, the system dynamically switches to the target communication rate corresponding to the current channel quality level; wherein, the correspondence between channel quality level and communication rate is directly proportional.
[0008] Optionally, receiving firmware data from the diagnostic device based on the target communication rate includes: Based on the target communication rate, negotiate with the diagnostic equipment to match the data transmission parameters of the target communication rate. The data transmission parameters include the single frame data length and the data block size. The diagnostic device continuously receives multiple data frames based on the negotiated single-frame data length until the reception of a data block is completed. Repeat the above data block receiving process until all firmware data has been received.
[0009] Optionally, continuously receiving multiple data frames transmitted by the diagnostic device based on a negotiated single-frame data length includes: Send a receive command to the CAN FD controller integrated into the ECU so that the CAN FD controller can receive multiple data frames continuously sent by the diagnostic device based on the negotiated single-frame data length; The received data frames are then written to the buffer.
[0010] Optionally, after receiving a data block, the method further includes: Integrity verification is performed on the data blocks based on a preset verification algorithm; If the verification fails, a negative response is returned to the diagnostic device to trigger the retransmission of the data block. If the verification passes, a block confirmation message is returned to the diagnostic device to trigger the transmission of the next data block.
[0011] Optionally, after returning a negative response, the following may also be included: The retransmission strategy is dynamically adjusted based on the current channel state. The dynamically adjusted retransmission strategy is sent to the diagnostic device for negotiation and confirmation.
[0012] Optionally, writing the received firmware data to the memory includes: When a write command is sent to the DMA controller, the DMA controller writes the data in the buffer to the target memory area of the memory; wherein the memory has a dual-bank structure, including the currently running firmware storage area and a spare firmware storage area, and the target memory area is the spare firmware storage area.
[0013] Secondly, a firmware flashing device for an on-board ECU is provided, comprising: The acquisition unit is used to acquire the current channel status of the vehicle communication bus in response to the flashing request sent by the diagnostic device. The switching unit is used to dynamically switch to the appropriate target communication rate according to the current channel status. A receiving unit is used to receive firmware data from a diagnostic device based on a target communication rate. The writing unit is used to write the received firmware data into the memory to complete the firmware flashing process.
[0014] Thirdly, a firmware flashing system for an in-vehicle ECU is provided, including: a diagnostic device, a gateway, and a target ECU; Diagnostic equipment is used to send firmware flashing requests and firmware data to the gateway; A gateway is used to forward flashing requests and firmware data to the target ECU; The target ECU is used to execute any of the methods in the first aspect.
[0015] Fourthly, an electronic device is provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements any of the methods of the first aspect.
[0016] This invention provides a firmware flashing method, apparatus, system, and electronic device for an on-board ECU. In response to a flashing request from a diagnostic device, the method acquires the current channel state of the on-board communication bus; dynamically switches to a suitable target communication rate based on the current channel state; receives firmware data from the diagnostic device based on the target communication rate; and writes the received firmware data into a memory to complete the firmware flashing process. This invention achieves adaptive adjustment of the communication rate by dynamically switching the target communication rate according to the channel state, dynamically balancing high bandwidth and high reliability. This avoids blindly initiating high-speed transmission under poor channel conditions, which can lead to wasted bandwidth resources and data loss, significantly improving the stability and effective throughput of the flashing process.
[0017] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This diagram illustrates the structure of a firmware flashing system for an in-vehicle ECU provided in an embodiment of the present invention. Figure 2 The flowchart illustrates a firmware flashing method for an in-vehicle ECU provided by an embodiment of the present invention; Figure 3 This diagram illustrates the structure of a firmware flashing device for an in-vehicle ECU provided in an embodiment of the present invention. Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present invention is shown. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0021] This invention provides a firmware flashing method for an in-vehicle ECU. This method is applied to an in-vehicle ECU firmware flashing system, such as... Figure 1 As shown, the system includes: a diagnostic device, a gateway, and a target ECU; wherein, the diagnostic device is used to run the flashing software and send firmware flashing requests and firmware data to the gateway; A gateway is used to forward flashing requests and firmware data to the target ECU; The target ECU is used to perform the firmware flashing method for the vehicle ECU.
[0022] In one specific embodiment, the target ECU integrates a central processing unit (CPU), a 5 Mbit / s CAN FD (Controller Area Network with Flexible Data-rate) controller, a DMA (Direct Memory Access) controller, and non-volatile memory with a dual-bank structure, such as Bank A and Bank B. Bank A serves as the current firmware storage area, storing the main program being executed; Bank B serves as a backup firmware storage area, used to receive new firmware versions to be updated or upgraded.
[0023] This embodiment replaces the traditional CAN FD controller with a high-performance CAN FD controller that supports a data segment rate of up to 5 Mbit / s through hardware upgrade. It is compatible with and supports communication rates of 5 Mbit / s and below, significantly improving the transmission bandwidth of firmware data and shortening the flashing time.
[0024] Meanwhile, the ECU integrates a DMA controller for efficient data transfer during firmware flashing. Specifically, DMA (Direct Memory Access) is a technology that enables high-speed data transfer between peripherals and memory, or between memory modules, without CPU intervention. In this embodiment, the DMA controller establishes a hardware linkage with the CAN FD controller. When the CAN FD controller receives data, it stores it in a buffer and automatically sends a transfer request to the DMA controller when the write conditions are met. The DMA controller then takes over bus control, directly transferring the received data from the buffer to the backup firmware storage area. The entire process requires no CPU involvement in data copying. The CPU is only awakened by an interrupt when data block reception is complete or an exception occurs, performing verification or error handling.
[0025] By introducing the DMA mechanism, the CPU load during data transfer is significantly reduced, allowing it to focus on critical tasks such as protocol processing, integrity verification, and Flash programming control, thereby improving the overall system response speed and flashing efficiency.
[0026] Furthermore, a dual-bank storage structure separates operation from flashing: while new firmware is being written to the backup bank (Bank B), the original firmware continues to run normally in the operating bank (Bank A), and system functionality remains unaffected. Once the new firmware has been fully written and verified, the system can be updated via boot configuration updates (such as modifying the Bootloader jump flag) to boot from Bank B on the next reboot, achieving seamless firmware upgrades. If the upgrade fails, the system can still revert to Bank A to continue running, ensuring the security and reliability of the flashing process.
[0027] Furthermore, to support the stable transmission of firmware data by the vehicle ECU firmware flashing system in this embodiment of the invention at a high-speed data segment rate of 5 Mbit / s, the physical layer specification of the communication system in this embodiment of the invention is configured to meet the ISO 11898-2:2016 standard. This standard defines the physical layer electrical characteristics that support high-speed data transmission, and compared with earlier versions (such as ISO 11898-2:2003), it significantly improves signal integrity and timing tolerance, and can effectively support data communication rates of up to 5 Mbit / s or even higher.
[0028] Based on the aforementioned firmware flashing system for vehicle ECUs, this invention provides a firmware flashing method for vehicle ECUs, such as... Figure 2 As shown, the execution subject of this method is the target ECU on the vehicle, and it includes the following steps: Step S201: In response to the flashing request sent by the diagnostic device, obtain the current channel status of the vehicle communication bus.
[0029] Diagnostic equipment is an external or on-board control device in an in-vehicle electronic system used to realize functions such as vehicle status reading, fault diagnosis, parameter configuration and firmware update. In the firmware flashing system of this invention embodiment, it serves as the master control terminal of the firmware flashing process, responsible for initiating and leading the entire flashing process.
[0030] In response to a firmware flashing request initiated by the diagnostic device, the target ECU establishes a communication session with the diagnostic device and obtains the current channel status of the vehicle communication bus.
[0031] In one example, the process of establishing a flashing request includes: the diagnostic device first sends an "Enter Programming Session" command (0x10 02), the target ECU responds successfully and returns a "Positive Response" (0x50 02), and switches to a high-bandwidth communication mode (e.g., 5M); then the diagnostic device sends a "Request Download" command (0x34), and the target ECU confirms the parameters and enters the data reception preparation state. During this process, the target ECU monitors the channel status of the bus. Step S202: Dynamically switch to the appropriate target communication rate based on the current channel status.
[0032] Step S203: Receive firmware data from the diagnostic device based on the target communication rate.
[0033] After determining the target communication rate, the target ECU and the diagnostic equipment establish a data transmission channel based on a negotiated frame structure and begin continuously receiving firmware data frames. For example, in 5 Mbit / s high-speed mode, high-throughput data reception is achieved through the data phase of the CAN FD protocol, ensuring full utilization of bandwidth resources when channel quality is good, and quickly completing the transmission of large amounts of firmware data.
[0034] Step S204: Write the received firmware data into the memory to complete the firmware flashing.
[0035] In this step, the memory is an on-chip flash memory.
[0036] This invention achieves adaptive adjustment of the communication rate by dynamically switching the target communication rate based on channel conditions. It dynamically balances high bandwidth and high reliability, avoiding the waste of bandwidth resources and data loss caused by blindly initiating high-speed transmission under poor channel conditions. This significantly improves the stability and effective throughput of the flashing process. Actual measured effective throughput can reach over 4 Mbps, which is more than 100% higher than traditional CAN FD (2 Mbps). Taking 1MB firmware as an example, the flashing time is reduced from 8 seconds to less than 3 seconds.
[0037] Based on the above embodiments, dynamically switching to the appropriate target communication rate according to the current channel state includes: Step S202A: Determine the current channel quality level of the vehicle communication bus based on the aforementioned channel status.
[0038] After establishing a diagnostic session, the target ECU collects and analyzes the operating status parameters of the vehicle communication bus in real time to assess the current channel quality. The channel status includes at least the bit error rate, and can also be comprehensively judged by combining indicators such as error frame count, signal jitter, bit timing deviation, and CRC check failure frequency.
[0039] In one example, the channel quality level is divided using the bit error rate as an example. For instance, when the bit error rate is lower than the first preset threshold (e.g., 1e-6), the channel quality level is excellent; when the bit error rate rises to the second preset threshold (e.g., 1e-5), the channel quality level is good; and when it rises to the third preset threshold (e.g., 1e-4), the channel quality level is poor.
[0040] Step S202B: Based on the current channel quality level and the preset correspondence between channel quality level and communication rate, dynamically switch to the target communication rate corresponding to the current channel quality level.
[0041] In one example, taking bit error rate as an example, when the channel quality is excellent, the highest supported rate (e.g., 5 Mbit / s) is maintained to maximize data throughput; when the channel quality is good, the rate is actively reduced to 2 Mbit / s to improve transmission reliability; if the bit error rate continues to deteriorate and the channel quality is poor, the writing process is paused and a diagnostic alarm message is returned to the diagnostic device to indicate communication abnormality, and transmission is resumed after the link is restored.
[0042] The relationship between channel quality level and communication rate is directly proportional. The higher the channel quality, the higher the communication rate can be.
[0043] In a specific application scenario, such as when a vehicle initiates an OTA upgrade in an underground parking garage, the initial error rate is high (Level 3), and the ECU pauses the OTA update. After the vehicle leaves the garage, the signal improves to Level 2, and the ECU automatically resumes receiving signals at 2 Mbit / s. Upon entering an open area, the upgrade proceeds to Level 1, switching to a high-speed 5 Mbit / s to complete the remaining data transmission. The entire process requires no manual intervention, achieving environmentally adaptive OTA updates.
[0044] The embodiments of the present invention make full use of the 5 Mbit / s high bandwidth when the channel is good, and actively reduce the speed or pause when the channel deteriorates, so as to avoid wasting bandwidth resources. The overall writing time is shorter and the success rate is higher, thus improving the robustness and efficiency of writing.
[0045] Although the communication rate has increased in the above embodiments, if the data frame structure is not matched to the high rate, the frame interval, flow control mechanism, etc. will not make full use of the bandwidth, and the writing efficiency will still not be high.
[0046] Therefore, based on the above embodiments, receiving firmware data from the diagnostic device based on the target communication rate includes: Step S203A: Based on the target communication rate, negotiate with the diagnostic equipment to match the data transmission parameters of the target communication rate.
[0047] To fully leverage the bandwidth potential of high communication rates, after determining the appropriate target communication rate, the target ECU further negotiates a set of matching data transmission parameters with the diagnostic equipment to achieve efficient and stable continuous data transmission.
[0048] The data transmission parameters include the length of a single frame (e.g., 128 bytes / frame, 64 bytes / frame) and the size of the data block (e.g., 4KB).
[0049] For example, when the target communication rate is 5 Mbit / s, negotiate to use a CAN FD long frame of 128 bytes / frame and configure the data block size to 16 frames / block; when the target communication rate is 2 Mbit / s, switch to 64 bytes / frame and set the data block size to 8 frames / block.
[0050] In another embodiment, when the target communication rate decreases, it indicates a deterioration in channel quality and an increase in the bit error rate. Therefore, the Forward Error Correction (FEC) mechanism can be activated for error correction. The principle of FEC is that the diagnostic device adds FEC error correction codes to each frame or data block. The target ECU uses the FEC decoding mechanism to locally correct minor bit errors without returning a negative response or triggering a retransmission. The retransmission mechanism is only activated when the error exceeds the FEC correction capability. This enhances the anti-interference capability during the flashing process.
[0051] Step S203B: Continuously receive multiple data frames sent by the diagnostic device based on the negotiated single-frame data length until the reception of a data block is completed.
[0052] After parameter negotiation is completed, the target ECU enters continuous receiving mode. The diagnostic equipment continuously sends multiple data frames according to the negotiated single frame length and block size, without waiting for the ECU to respond for each frame.
[0053] In one feasible implementation, continuously receiving multiple data frames transmitted by the diagnostic device based on a negotiated single-frame data length includes: Step S203B1: Send a receive command to the CAN FD controller integrated in the ECU so that the CAN FD controller can receive multiple data frames continuously sent by the diagnostic device based on the negotiated single-frame data length.
[0054] The receive command triggers the CAN FD controller to enter continuous receive mode, enabling it to automatically identify and receive data frames that conform to the protocol format without the need for CPU intervention frame by frame.
[0055] In this step, the CAN FD controller specifically adopts a 5M CAN FD controller.
[0056] Step S203B2: Write the received data frames into the buffer.
[0057] In this step, if the buffer usage exceeds 80%, a flow control frame (0x30) is sent to the diagnostic device to notify it to pause transmission.
[0058] Compared to existing technologies where the CPU interrupts to write data after each frame is sent, resulting in low efficiency, this application uses a block transfer mode, receiving a data block size continuously before writing, thus improving write efficiency.
[0059] After receiving a data block, the method further includes: Step S203C: Perform integrity verification on the data block based on the preset verification algorithm.
[0060] After the target ECU writes all data frames of a complete data block into the RAM cache via DMA, the CPU is woken up and starts the integrity verification process.
[0061] The ECU performs consistency verification on all valid data in the data block based on a preset verification algorithm. The verification algorithm includes at least one or more of the following combinations: CRC32 (Cyclic Redundancy Check), Checksum (Accumulated Sum Check), and hash check (such as SHA-1, SHA-256, used for high-security scenarios). The verification scope covers the payload data of all frames in the data block, ensuring that no data corruption, out-of-order delivery, or loss occurs during high-speed transmission.
[0062] Step S203D: If the verification fails, a negative response is returned to the diagnostic device to trigger the retransmission of the data block.
[0063] In this step, a negative response is, for example, NRC 0x24 (the requested data failed verification). Upon receiving a negative response, the diagnostic device identifies the current data block transmission as abnormal and automatically retransmits all frames of that data block without needing to re-establish the session or interrupt the process.
[0064] By performing validation before data is written, a negative response is immediately returned upon detecting an anomaly, triggering precise retransmission and preventing erroneous data from entering subsequent processing steps.
[0065] Step S203E: If the verification passes, return block confirmation information to the diagnostic device to trigger the transmission of the next data block.
[0066] After the verification is successful, the ECU returns a block confirmation message ACK (0x71) to the diagnostic equipment.
[0067] The embodiments of the present invention perform independent verification on the entire data block, which improves efficiency compared to the single-frame confirmation method, and makes up for the limitations of single-frame CRC, effectively preventing potential risks such as data misordering, missing frames, and DMA transfer errors.
[0068] Step S203F: Repeat the above data block reception and verification process until all firmware data has been received.
[0069] To avoid the rate drop caused by frequent retransmissions, the following is also included after returning a negative response: Step A: Dynamically adjust the retransmission strategy based on the current channel status.
[0070] After the target ECU returns a negative response to the diagnostic equipment to trigger data block retransmission, in order to further improve the efficiency and success rate of the retransmission process, the ECU does not simply request retransmission as is, but dynamically optimizes the retransmission strategy based on the current channel status of the vehicle communication bus.
[0071] The retransmission strategy can be adjusted by re-determining the target communication rate and data frame length based on the channel state, as described above, and negotiating data transmission parameters that match the target rate. This will not be elaborated further here.
[0072] Step B: Send the dynamically adjusted retransmission strategy to the diagnostic device for negotiation and confirmation.
[0073] The target ECU sends the adjusted retransmission parameters to the diagnostic device, requesting it to perform retransmission according to the new strategy. Upon receiving the suggestion, the diagnostic device performs a local feasibility assessment (such as whether it supports the rate, frame length, etc.). If it is compatible, it returns a confirmation response, and both parties complete the negotiation of retransmission parameters. If it is not feasible, it sends a rejection response, and the ECU can further downgrade the strategy or maintain the original parameters for retransmission.
[0074] Through the embodiments of the present invention, an ECU-led intelligent retransmission negotiation mechanism is realized, so that the retransmission behavior is no longer a simple retransmission, but a recovery process that is adaptively optimized according to the link status.
[0075] Based on the above embodiments, writing the received firmware data into the memory includes: Step S204A: When a write command is sent to the DMA controller, the DMA controller writes the data in the buffer to the target memory area.
[0076] The memory has a dual-bank structure, including a currently running firmware storage area and a spare firmware storage area, with the target storage area being the spare firmware storage area.
[0077] In one example, the CPU configures the DMA controller's source address (receive buffer in RAM), destination address (target memory area in non-volatile memory), transfer length, and data alignment, and then initiates the DMA transfer. The DMA controller takes over the system bus and, without CPU intervention, directly moves the firmware data from the buffer to the designated area of the on-chip Flash memory.
[0078] By enabling automatic data transfer through the DMA mechanism, the CPU only needs to initialize configuration and complete final programming, freeing up its resources for high-value tasks such as protocol processing and error monitoring. This significantly reduces the CPU load.
[0079] Based on the same inventive concept, a firmware flashing device for an on-board ECU is provided, such as... Figure 3 As shown, it includes: The acquisition unit 301 is used to acquire the current channel status of the vehicle communication bus in response to a flashing request sent by the diagnostic device. The switching unit 302 is used to dynamically switch to the appropriate target communication rate according to the current channel state; The receiving unit 303 is used to receive firmware data from the diagnostic device based on the target communication rate; The writing unit 304 is used to write the received firmware data into the memory to complete the firmware flashing.
[0080] Based on the same technical concept, embodiments of the present invention also provide an electronic device, such as... Figure 4 As shown, it includes a processor 401, a communication interface 402, a memory 403, and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404.
[0081] Memory 403 is used to store computer programs; The processor 401 is used to execute the program stored in the memory 403 to implement the firmware flashing method of the vehicle ECU.
[0082] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0083] The communication interface is used for communication between the aforementioned electronic devices and other devices.
[0084] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0085] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0086] The firmware flashing device for an on-board ECU provided in this embodiment of the invention can be specific hardware on the device or software or firmware installed on the device. The implementation principle and technical effects of the device provided in this embodiment of the invention are the same as those in the foregoing method embodiments. For the sake of brevity, any parts not mentioned in the device embodiments can be referred to the corresponding content in the foregoing method embodiments. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can all be referred to the corresponding processes in the above method embodiments, and will not be repeated here.
[0087] In the embodiments provided by this invention, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0088] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0089] In addition, the functional units in the embodiments provided by the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0090] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0091] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0092] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, 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. All should be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for flashing firmware for an on-board ECU, characterized in that, include: In response to a flash request sent by a diagnostic device, obtain the current channel status of the vehicle communication bus; Based on the current channel state, dynamically switch to the appropriate target communication rate; Receive firmware data from the diagnostic device based on the target communication rate; The received firmware data is written to the memory to complete the firmware flashing process.
2. The method according to claim 1, characterized in that, The step of dynamically switching to the appropriate target communication rate based on the current channel state includes: The current channel quality level of the vehicle communication bus is determined based on the aforementioned channel state; the parameters characterizing the channel state include at least the bit error rate. Based on the current channel quality level and the preset correspondence between channel quality level and communication rate, the system dynamically switches to the target communication rate corresponding to the current channel quality level; wherein the correspondence between channel quality level and communication rate is directly proportional.
3. The method according to claim 2, characterized in that, The process of receiving firmware data from the diagnostic device based on the target communication rate includes: Based on the target communication rate, negotiate with the diagnostic device to match the data transmission parameters of the target communication rate, wherein the data transmission parameters include single frame data length and data block size; The diagnostic device continuously receives multiple data frames based on the negotiated single-frame data length until the reception of a data block is completed. Repeat the above data block receiving process until all firmware data has been received.
4. The method according to claim 3, characterized in that, The continuous reception of multiple data frames sent by the diagnostic device based on the negotiated single-frame data length includes: Send a receive command to the CAN FD controller integrated in the ECU so that the CAN FD controller can receive multiple data frames continuously sent by the diagnostic device based on the negotiated single-frame data length; The received data frames are then written to the buffer.
5. The method according to claim 3, characterized in that, After receiving a data block, the method further includes: The data block is subjected to integrity verification based on a preset verification algorithm; If the verification fails, a negative response is returned to the diagnostic device to trigger the retransmission of the data block. If the verification passes, a block confirmation message is returned to the diagnostic device to trigger the transmission of the next data block.
6. The method according to claim 5, characterized in that, After returning a negative response, it also includes: Based on the current channel state, the retransmission strategy is dynamically adjusted; The dynamically adjusted retransmission strategy is sent to the diagnostic device for negotiation and confirmation.
7. The method according to claim 4, characterized in that, The step of writing the received firmware data into the memory includes: When a write command is sent to the DMA controller, the DMA controller writes the data in the buffer to the target storage area of the memory; wherein the memory has a dual-bank structure, including a currently running firmware storage area and a spare firmware storage area, and the target storage area is the spare firmware storage area.
8. A firmware flashing device for an on-board ECU, characterized in that, include: The acquisition unit is used to acquire the current channel status of the vehicle communication bus in response to the flashing request sent by the diagnostic device. The switching unit is used to dynamically switch to the appropriate target communication rate according to the current channel state. The receiving unit is configured to receive firmware data from the diagnostic device based on the target communication rate; The writing unit is used to write the received firmware data into the memory to complete the firmware flashing.
9. A firmware flashing system for an on-board ECU, characterized in that, include: Diagnostic equipment, gateway, and target ECU; The diagnostic device is used to send a firmware flashing request and firmware data to the gateway. The gateway is used to forward the flashing request and firmware data to the target ECU; The target ECU is used to perform the method described in any one of claims 1-7.
10. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; The memory is used to store computer programs; When the processor executes the program stored in the memory, it implements the method described in any one of claims 1-7.