Method for determining time source, gateway controller and vehicle
By acquiring and configuring time source information in the gateway controller, the target time source can be determined from two time sources, thus solving the adaptability and flexibility issues of the vehicle gateway controller under different vehicle models, and achieving cost control and timestamp accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-31
- Publication Date
- 2026-04-14
AI Technical Summary
Existing vehicle gateway controllers have poor compatibility with different vehicle models and hardware configurations, resulting in high R&D costs and low flexibility. They also cannot flexibly switch time acquisition logic, increasing production and maintenance complexity.
By acquiring time source configuration information, a target time source is determined from at least two time sources, and time information is generated, including time sources based on time messages and clock chips. Configuration and verification are performed using a microprocessor and memory, supporting both wireless terminal modules and vehicle models without wireless terminal modules.
It enables flexible configuration of time sources for different vehicle models, reduces the R&D cost and production complexity of gateway controllers, improves adaptability and ease of maintenance, and ensures the accuracy of security log timestamps.
Smart Images

Figure CN121864582A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of vehicles, and more particularly to a method for determining a time source, a gateway controller, and a vehicle. Background Technology
[0002] With the increasing electrification and networking of automobiles, automotive information security risks are becoming increasingly prominent. Therefore, the entire vehicle needs to record information security logs, and all security logs must include accurate timestamps to enable the tracing, investigation, and determination of responsibility for security incidents. This requirement has become the core design basis for the gateway controller's time acquisition function.
[0003] However, current time acquisition solutions for vehicle gateway controllers have the following technical limitations: 1. Poor time source adaptability: Currently, most vehicles adopt a single time source design. If the vehicle is equipped with a wireless terminal module (such as a 4G / 5G vehicle networking module or T-BOX), the gateway receives its time signal through the CAN bus. If the vehicle does not have a wireless terminal module, the gateway needs to rely on its own independent timing unit. However, the time acquisition logic in the two scenarios cannot be flexibly switched. Therefore, different gateway controllers need to be designed for different scenarios. This leads to the need to redevelop hardware or software for different vehicle models during the production stage, thereby increasing R&D costs and time.
[0004] 2. Insufficient configuration flexibility: Different vehicle models have different electronic and electrical architectures. To adapt to models without wireless terminal modules, the gateway controller needs to use different hardware. Choosing different time sources also requires developing different software. During later maintenance or vehicle model adaptation, the gateway controller needs to be disassembled for physical modification or reprogramming, which is complex and can easily lead to system stability risks, failing to meet the "maintainability" design requirements of automotive electronics.
[0005] Therefore, there is an urgent need for a gateway controller that can configure time sources and adapt to different vehicle hardware configurations, thus solving the problems of poor adaptability and low flexibility of existing solutions. Summary of the Invention
[0006] This application provides a method for determining a time source, a gateway controller, and a vehicle. The gateway controller can configure the time source and adapt to different vehicle hardware configurations, solving the problems of poor adaptability and low flexibility in existing solutions.
[0007] This application provides a method for determining a time source, including: Obtain time source configuration information; Based on the time source configuration information, determine the target time source from at least two time sources; Time information is generated based on the target time source.
[0008] In one possible implementation of the first aspect, at least two time sources include: a time source based on time messages and a time source based on clock chips.
[0009] In one possible implementation of the first aspect, obtaining the time configuration information includes: Read time source configuration information; Based on the successful reading of the time source configuration information, execute "Based on the time source configuration information, determine the target time source from at least two time sources"; If reading the time source configuration information fails, configure the time source configuration information and jump to "Read Time Source Configuration Information".
[0010] In one possible implementation of the first aspect, determining the target time source from at least two time sources based on time source configuration information includes: Based on the time source configuration information as the first time source configuration information, the time source based on the time message is determined as the target time source; Based on the time source configuration information as the second time source configuration information, the time source based on the clock chip is determined as the target time source.
[0011] In one possible implementation of the first aspect, the target time source is a time source based on a time message, and the time information generated based on the target time source includes: Obtain time messages and generate time information based on time messages.
[0012] In one possible implementation of the first aspect, obtaining the time message and generating time information based on the time message includes: Obtain the time message; Verify the time message; Based on successful verification of the time message, extract the time information from the time message.
[0013] In one possible implementation of the first aspect, the target time source is a clock chip-based time source, and the generation of time information based on the target time source includes: Configure initial time; Based on the initial time, the clock chip is activated to start timing and generate time information.
[0014] One possible implementation of the first aspect also includes: The system periodically acquires time information and generates timestamp information based on the last acquired time information when a security event is detected, so that the security log information can be embedded with the timestamp information.
[0015] Secondly, embodiments of this application provide a gateway controller whose time source is determined by the method provided in the first aspect.
[0016] In one possible implementation of the first aspect, the gateway controller includes: microprocessor; The clock chip is electrically connected to the microprocessor. A first memory is electrically connected to a microprocessor. The first memory is used to store time source configuration information. The microprocessor is used to determine a target time source from at least two time sources based on the time source configuration information. The first power source is electrically connected to the microprocessor.
[0017] In one possible implementation of the second aspect, the first memory is an electrically erasable programmable read-only memory.
[0018] In one possible implementation of the second aspect, the clock chip is connected to the microprocessor via an I2C interface.
[0019] In one possible implementation of the second aspect, at least two time sources include: a time source based on time messages and a time source based on clock chips.
[0020] In one possible implementation of the second aspect, the first memory is further used to store the time information of the last time it was written, the time information is periodically written to the first memory, and the time information of the current time it is written to the memory overwrites the time information of the time written earlier.
[0021] In one possible implementation of the second aspect, the microprocessor includes a current time buffer, and the log information includes a timestamp generated based on the time information stored in the current time buffer.
[0022] In one possible implementation of the second aspect, the gateway controller further includes a bus transceiver module, which is connected to the microprocessor and the controller area network bus respectively.
[0023] In one possible implementation of the second aspect, a second memory is also included, which is connected to the microprocessor and is used to store log information.
[0024] In one possible implementation of the second aspect, the second memory is a flash memory.
[0025] Thirdly, embodiments of this application also provide a vehicle, including a gateway controller, wherein the time source of the gateway controller is determined by the method provided in the first aspect, and / or the gateway controller is a gateway controller provided in the second aspect.
[0026] The method for determining a time source provided in this application can configure the time source based on time source configuration information. Therefore, the time source can be configured by setting corresponding time source configuration information for different vehicle models. That is, this method for determining the time source is suitable for both vehicle models without and with wireless terminal modules. Therefore, the method provided in this application can be used to determine the time source for various different vehicle models; only the corresponding time source configuration information needs to be configured for different vehicle models during assembly. The gateway controller provided in this application can effectively solve the problems of poor adaptability and low flexibility in existing solutions. Attached Figure Description
[0027] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0028] Figure 1 A flowchart illustrating a method for determining a time source provided in an embodiment of this application; Figure 2 This application provides a schematic diagram of a process for obtaining time configuration information in an embodiment of the present application. Figure 3 This is a schematic diagram illustrating a process for determining a target time source from at least two time sources based on time source configuration information, as provided in an embodiment of this application. Figure 4 This is a schematic diagram illustrating a process for obtaining a time message and generating time information based on the time message, as provided in an embodiment of this application. Figure 5 This application provides a schematic diagram of a process for generating time information based on a target time source, as illustrated in an embodiment of the present application. Figure 6 A schematic diagram of a gateway controller provided in an embodiment of this application; Figure 7 This is a schematic diagram of a gateway controller provided in an embodiment of this application.
[0029] 100. Gateway controller; 101. Microprocessor; 102. Clock chip; 103. First memory; 104. First power supply; 105. Second memory; 106. Bus transceiver module. Detailed Implementation
[0030] To better understand the technical solution of this application, the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0031] It should be understood that the described embodiments are merely some, not all, of the embodiments in this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.
[0032] The terminology used in the embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. The singular forms “a,” “the,” and “the” used in the embodiments of this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0033] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0034] like Figure 1 As shown in the embodiments of this application, this application provides a method for determining a time source, including: S100, obtain time source configuration information.
[0035] Time source configuration information is used to specify the time source. There is a one-to-one correspondence between time configuration information and time sources. Different time sources correspond to different time sources. For example, time source configuration information includes first time source configuration information and second time source configuration information, where the first time source configuration information corresponds to the first time source, and the second time source configuration information corresponds to the second time source. The time source configuration information can be preset code; for example, in one possible implementation, the first time source configuration information is 0x01, and the second time source configuration information is 0x00.
[0036] Time source configuration information can be stored in memory and retrieved by reading data. Specifically, for example... Figure 2 As shown, in one possible implementation, obtaining time configuration information includes: S110, read time source configuration information.
[0037] In step S110, time source configuration information can be read from the memory that stores time configuration information.
[0038] S120, based on successfully reading the time source configuration information, execute "Based on the time source configuration information, determine the target time source from at least two time sources".
[0039] In step S120, if the time source configuration information can be successfully read, it means that the time source configuration information has been configured and can be successfully read. At this time, the next step can be carried out, namely, "based on the time source configuration information, determine the target time source from at least two time sources".
[0040] S130, based on the failure to read the time source configuration information, configure the time source configuration information and jump to "Read Time Source Configuration Information".
[0041] In step S130, a data read failure may occur if the time source configuration information is used for the first time or if the time source configuration information is corrupted. Specifically, when the time source configuration information is used for the first time, it has not yet been configured; that is, the memory does not store the time source configuration information, leading to data read failure. Corruption of the time source configuration information is another reason for read failure. However, regardless of the cause, it can be repaired by configuring the time source configuration information. That is, the time source configuration information can be configured by rewriting it into the memory. In a specific implementation, this can be done as follows: S131, based on the time source configuration read failure, change the time source configuration information item to a pending configuration state; S132, based on the time source configuration information being in a pending configuration state, configure the time source configuration information. In the specific implementation of step S132, a configuration command (diagnostic service ID: 0x2E) can be sent via a UDS (Unified Diagnostic Services) diagnostic tool to write a 1-byte configuration word. When writing the configuration word, based on the vehicle model and whether the vehicle is equipped with a wireless terminal module, a configuration word corresponding to that vehicle model can be written. For example, if the vehicle is equipped with a wireless terminal module, a configuration word corresponding to the time source based on the time message is written (e.g., 0x01); if the vehicle is not equipped with a wireless terminal module, a configuration word corresponding to the time source based on the clock chip is written (e.g., 0x00).
[0042] After configuring the time source information, it is necessary to reread the time source configuration information to determine the time source.
[0043] S200, based on time source configuration information, determines the target time source from at least two time sources.
[0044] In step S200, since different time source configuration information corresponds to different time sources, the target time source can be determined based on the time source configuration information. The target time source refers to the selected time source, that is, the time source corresponding to the read time source configuration information.
[0045] In one possible implementation, at least two time sources are included: a time source based on time messages and a time source based on a clock chip. The time source based on time messages originates from time messages received from the CAN bus. The time source based on a clock chip originates from a clock chip (i.e., an RTC chip).
[0046] like Figure 3 As shown, in one possible implementation, determining the target time source from at least two time sources based on time source configuration information includes: S210, based on the time source configuration information as the first time source configuration information, determine the time source based on the time message as the target time source.
[0047] Taking the first time source configuration information as 0x01 as an example. In step S210, if the obtained time configuration information is 0x01, then the time source on which the timestamp and time information are based is determined to be a time source based on time messages.
[0048] S220, based on the time source configuration information as the second time source configuration information, determine the time source based on the clock chip as the target time source.
[0049] Taking the first time source configuration information as 0x00 as an example. In step S220, if the obtained time configuration information is 0x00, then the time source on which the timestamp and time information are based is determined to be a time source based on a clock chip.
[0050] S300 generates time information based on the target time source.
[0051] In step S300, after determining the target time source, time information can be generated from the target time source. The time information is stored in a time buffer within the memory. When time information is needed, it is read from the time buffer. To save storage space and considering the dynamic nature of time, time information is periodically stored in the time buffer, using an overwrite method; that is, the time information currently stored in the time buffer overwrites the time information stored in the time buffer the previous time. Here, "the previous time" refers to the time preceding the current time. Since the time information stored in the time buffer is the most recent time information, the time buffer can also be called the current time buffer, indicating that it is used to read the current time.
[0052] In one possible implementation, the target time source is a time source based on a time message, and the time information generated based on the target time source includes: S310: Obtain the time message and generate time information based on the time message.
[0053] In step S310, time messages are periodically received from the CAN bus, and time information is extracted from the received time messages. The time information can be used to generate a timestamp when a security event is detected.
[0054] After receiving the time message, it needs to be verified. Therefore, such as Figure 4 As shown, in one possible implementation, obtaining the time message and generating time information based on the time message includes: S311, Get Time Message.
[0055] In step S311, a time message is received on the CAN bus.
[0056] S312 verifies the time message.
[0057] In step S312, after receiving the time message, the CAN_ID and data length (8 bytes) are verified first, and the validity of the data is checked.
[0058] S313, based on successful verification of the time message, extract time information from the time message.
[0059] If the verification passes, the BCD code is converted into decimal time data and updated to the "current time buffer" inside the memory; if the verification fails, the message is discarded and the last valid time in the time buffer is used.
[0060] like Figure 5 As shown, in one possible implementation, the target time source is a clock chip-based time source, and the time information generated based on the target time source includes: S301, Configure initial time.
[0061] In step 301, an initial time write command (service ID: 0x2E) is sent through the UDS diagnostic instrument to send 6 bytes of BCD code time data (2 bytes of year, 1 byte of month, 1 byte of day, 1 byte of hour, 1 byte of minute, and 1 byte of second) to the microprocessor; the microprocessor writes the data sequentially into the time register of the RTC chip through the I2C interface, and at the same time backs up the data to the memory (e.g., EEPROM) to complete the initial calibration.
[0062] S302, based on the initial time, starts the clock chip to begin timing and generates time information.
[0063] In step S302, RTC timing is performed based on the initial writing time, and the time information is written to the time buffer of the memory at certain intervals to overwrite the time of the last writing, so as to ensure that the time recorded after the vehicle is powered off is not lost.
[0064] In one possible implementation, the method further includes: The system periodically acquires time information and generates timestamp information based on the last acquired time information when a security event is detected, so that the security log information can be embedded with the timestamp information.
[0065] In this implementation, the time information is updated periodically to ensure accuracy. For example, a time source based on time messages updates every 1000ms, while a time source based on a clock chip updates every 10ms. When a security event is detected, time information is read from the time buffer and used as a timestamp. This timestamp is then embedded into the security log information. In other words, the security log information consists of the security event and the timestamp information packaged together.
[0066] In this implementation, when the target time source is a clock chip-based time source, upon detecting a security event, the MCU reads the "current time buffer" data, generates a timestamp, and packages the security log along with the timestamp into a FLASH chip. The after-sales service station can download the security log and upload it to the cloud platform via an after-sales diagnostic tool. When the target time source is a time message-based time source, upon detecting a security event (such as CAN bus intrusion or unauthorized ECU access), the MCU reads the "current time buffer" data, generates a timestamp, and packages the security log along with the timestamp into a CAN message, sends it to the wireless terminal module, and finally uploads it to the cloud platform.
[0067] In summary, the time source determination method provided in this application can determine the time source configuration information based on the vehicle model. Then, by simply writing the time source configuration information into the gateway controller for configuration, the target time source can be determined automatically. Therefore, the method provided in this application is applicable to both vehicles equipped with and without wireless terminal modules. That is, regardless of the type of vehicle, the method provided in this application can be used to determine the time source, thereby saving on the hardware and software development costs of the gateway controller.
[0068] Secondly, embodiments of this application provide a gateway controller whose time source is determined by the method of any one of claims 1-8.
[0069] The gateway controller provided in this application can determine the time source configuration information based on the vehicle model. Then, by simply writing the time source configuration information into the gateway controller for configuration, the target time source can be determined automatically. Furthermore, the gateway controller provided in this application is applicable to both vehicles equipped with and without a wireless terminal module. Therefore, regardless of whether a vehicle is equipped with a wireless terminal module, the time source can be determined by configuring the gateway controller provided in this application, thereby saving on the hardware and software development costs of the gateway controller.
[0070] like Figure 6 As shown, one embodiment of this application provides a gateway controller 100, including: a microprocessor 101 (Microcontroller Unit, i.e., MCU), a clock chip 102 (Real-Time Clock, i.e., RTC), a first memory 103, and a first power supply 104. The microprocessor 101 is used to implement the overall control and data processing of the gateway controller 100.
[0071] Clock chip 102 is electrically connected to microprocessor 101. When operating, clock chip 102 performs timing, thereby generating time information. In one possible implementation, clock chip 102 is model RA8900CE. The RA8900CE clock chip 102 has high-precision timing capabilities, adaptable to both vehicle applications with and without wireless terminal modules, thus ensuring the accuracy of the security log timestamp. This implementation uses the RA8900CE clock chip 102, which helps ensure that the security log timestamp complies with relevant national standards.
[0072] The first power supply 104 is electrically connected to the microprocessor 101. In one possible implementation, the first power supply 104 includes a system base chip (SBC). The power management module is used to provide power to the gateway controller 100. For example, the power management module includes a power converter used to convert the received voltage into the power supply voltage of the gateway controller 100, that is, the output voltage of the power converter is the power supply voltage of the gateway controller 100. Figure 6 As shown, KL31 of the first power supply 104 is the positive terminal, KL30 is the ground terminal, and KL15 is the ignition control power terminal. That is, KL31 is used to electrically connect to the positive terminal of the external power supply, KL30 is used to electrically connect to the negative terminal or ground terminal of the external power supply, and KL15 is activated by the ignition switch to power the gateway controller 100 during startup or operation, specifically, it can power the microprocessor 101.
[0073] The first memory 103 is electrically connected to the microprocessor 101. The first memory 103 stores time source configuration information. The microprocessor 101 determines a target time source from at least two time sources based on the time source configuration information. The at least two time sources include a time source based on time messages and a time source based on the clock chip 102, wherein the time messages are received based on the controller area network bus (i.e., the CAN bus). The time source configuration information is used to characterize the time source. In one possible implementation, the time source configuration information includes a time source configuration word. Based on the time source configuration word, the microprocessor 101 can determine the target time source. The target time source refers to the time source specified by the microprocessor, that is, the time source selected as the time source based on the time source configuration information. For example, when the time source configuration word is the first configuration word, the target time source is determined to be the time source based on the clock chip 102; when the time source configuration word is the second configuration word, the target time source is determined to be the time source based on the time messages received on the CAN bus. In one possible implementation, the first configuration word can be 0x00, and the second configuration word can be 0x01.
[0074] In this embodiment, the gateway controller 100 can configure the time source based on the time source configuration information. Therefore, the time source configuration can be achieved by setting the corresponding time source configuration information for different vehicle models. For example, for vehicle models without a wireless terminal module, the time source configuration information is set as a first configuration word. After the gateway controller 100 is powered on, the microprocessor 101 determines the target time source as the time source based on the clock chip 102 based on the first configuration word. For vehicle models with a wireless terminal module, the time source configuration information is set as a second configuration word. After the gateway controller 100 is powered on, the microprocessor 101 determines the target time source as the time source based on the time message received from the CAN bus based on the second configuration word. That is, the same gateway controller 100 is suitable for both vehicle models without and vehicle models with wireless terminal modules. Therefore, the gateway controller 100 provided in this application embodiment can be used for various different vehicle models. It is only necessary to configure the corresponding time source configuration information for different vehicle models during assembly.
[0075] In summary, the gateway controller 100 provided in this application embodiment can effectively solve the problems of poor adaptability and low flexibility of existing solutions.
[0076] like Figure 7 As shown, in one possible implementation, the gateway controller 100 further includes a bus transceiver module 106, which is connected to the microprocessor 101 and the controller local area network bus.
[0077] The bus transceiver module 106 is used to realize the transmission and reception of information between the bus and the microprocessor 101. For example, it receives time messages received from the CAN bus and sends them to the microprocessor 101, and receives instructions sent by the microprocessor 101 and sends them to the CAN bus. In one possible implementation, the bus transceiver module 106 includes several transceivers. The cooperation of several transceivers can improve the efficiency of information transmission and reception and ensure the accuracy of information transmission and reception.
[0078] like Figure 7 As shown, in one possible implementation, the gateway controller 100 further includes a second memory 105, which is connected to the microprocessor 101 and is used to store log information.
[0079] To reduce the storage pressure on the first memory 103, a second memory 105 can be added to store log information. The log information includes safety log information, which includes timestamps. This configuration ensures the tracing, investigation, and determination of responsibility for vehicle driving safety incidents.
[0080] In one possible implementation, the second memory 105 is a flash memory (i.e., FLASH memory), which can store log information for a long time, thereby ensuring the security of the log information. In another possible implementation, the vehicle adapted to the gateway controller 100 does not have a wireless terminal module. When the usage capacity of the second memory 105 reaches a threshold, a fault code is generated. Based on this fault code, the vehicle after-sales service provider uses an external network device (such as a computer terminal) to upload the security log to the backend server for future traceability. The threshold is 85%-95%, for example, 90% or 95%.
[0081] In one possible implementation, the first memory 103 is an electrically erasable programmable read-only memory (EEPROM). An EEPROM ensures that the information it stores is not lost after power failure. Therefore, since the time source configuration information is stored in the first memory 103, it will not be lost even if power is lost. This allows the gateway controller 100 to directly read the time source configuration information from the first memory 103 after power is restored, eliminating the need for reconfiguration and thus improving the efficiency of time source configuration.
[0082] In one possible implementation, the clock chip 102 is connected to the microprocessor 101 via an I2C interface. The I2C interface has advantages such as simple communication lines, multi-device compatibility, low power consumption, and low cost.
[0083] In this implementation, the SBC module, microprocessor 101, transceiver, clock chip 102, first memory 103, and second memory 105 are connected through standardized pins and communication interfaces to form a highly reliable hardware system.
[0084] In one possible implementation, the first memory 103 is also used to store the time information of the last time it was written. The time information is periodically written to the first memory 103, and the time information of the current time it is written overwrites the time information of the time written earlier.
[0085] In this implementation, the time information can be real-time information. When real-time information is written, it overwrites the previously written real-time information, which helps to save storage space.
[0086] In one possible implementation, the time information is generated based on the clock chip 102. The time information can be real-time time information, which is generated based on the timing device inside the clock chip 102. The clock chip 102 is given an initial time information, and the clock chip 102 automatically starts timing to generate the real-time time information.
[0087] In one possible implementation, time information is generated based on time messages. The CAN bus periodically receives time message information and periodically sends it to the microcontroller. The microcontroller parses the received time messages to generate time information. The time information can be real-time time information, generated based on the periodically received time message information.
[0088] When a security incident occurs, the real-time time information is used as a timestamp and packaged together with the security incident to produce security log information, which will be used for subsequent tracing, investigation and responsibility determination of the security incident.
[0089] In one possible implementation, the first memory 103 is also used to store initial time information. This initial time information can be obtained based on a time message or set manually. For example, when there is no wireless terminal module in the vehicle, the initial time information is set manually. The initial time information is read by the microprocessor 101 and sent to the clock chip 102, which then starts timing to generate the real-time time. When there is a wireless terminal module in the vehicle, the initial time information can be generated based on a time message received from the CAN bus.
[0090] In one possible implementation, the microprocessor 101 includes a current time buffer, and the log information includes a timestamp, which is generated based on the time information stored in the current time buffer. The time information is stored in the current time buffer, so when real-time time is needed, i.e., when timestamp information needs to be added to the log, the time information can be directly read from the current time buffer. In this implementation, the time information is real-time time information, meaning that real-time time information is stored in the current time buffer.
[0091] To better understand the gateway controller provided in this application embodiment, the specific working process of the gateway controller will be described below: 1. Time source configuration (written to the configuration word via UDS diagnostics) After the gateway controller powers on, the MCU first reads the "time source configuration word" from the EEPROM. If the read fails (e.g., during initial power-on or if the configuration word is corrupted), it enters the "pending configuration" state. A configuration command (diagnostic service ID: 0x2E) needs to be sent via the UDS diagnostic tool to write a 1-byte configuration word, defined as follows: (1) Configuration word = 0x01: Select “CAN bus time source” - adapt to the scenario of the whole vehicle equipped with wireless terminal module, and use the time message received by CAN bus as the timestamp reference; (2) Configuration word = 0x00: Select "Gateway's own RTC time source" - adapt to the scenario where the whole vehicle has no wireless terminal module, and use the timing data of the RTC chip as the timestamp reference; (3) After the configuration word is written, the MCU stores it in the EEPROM and automatically loads it on the next power-on, without the need for repeated configuration.
[0092] 2. Initial Time Setting The UDS diagnostic tool sends an initial time write command (service ID: 0x2E) to send 6 bytes of BCD code time data (2 bytes of year, 1 byte of month, 1 byte of day, 1 byte of hour, 1 byte of minute, and 1 byte of second) to the MCU. The MCU writes the data sequentially to the time register of the RTC chip via the I2C interface, and at the same time backs up the data to the EEPROM, completing the initial calibration. (1) RTC time source scenario (configuration word = 0x00): After the gateway is powered on, it performs RTC timing based on the initial time written, and writes the time information into the EEPROM at certain intervals to overwrite the time written last time, so as to ensure that the time recorded after the gateway loses power is not lost. In addition, when the configuration word is the RTC event source scenario, if the initial time in the EEPROM is the default value of all "FF", the gateway records a fault code to indicate that the initial time has not been written.
[0093] (2) CAN bus time source scenario (configuration word = 0x01): After the gateway is powered on, if the configuration word is identified as a CAN bus time source scenario, the initial time written in the EEPROM will be ignored and the RTC timer will not be started. The time information will be extracted using the time message received on the CAN bus.
[0094] 3. Time Acquisition and Timestamp Generation (1) RTC time source scenario (configuration word = 0x00): The MCU reads the time register of the RTC chip via the I2C interface at 100ms intervals, with a 10ms timeout mechanism enabled to avoid I2C bus blocking. The read time is updated to the internal "current time buffer". When a security event is detected, the MCU reads the data in the "current time buffer", generates a timestamp, and packages the security log together with the timestamp and stores it in the internal FLASH chip. The after-sales service station can download the security log and upload it to the cloud platform via the after-sales diagnostic instrument.
[0095] (2) CAN bus time source scenario (configuration word = 0x01): The MCU listens for time messages in real time via the CAN interface (the wireless terminal module sends messages every 1000ms). After receiving the message, first verify the CAN_ID and data length (8 bytes), and check the validity of the data; if the verification passes, convert the BCD code into decimal time data and update the internal "current time buffer"; if the verification fails, discard the message and use the last valid time in the buffer. When a security event (such as CAN bus intrusion or unauthorized ECU access) is detected, the MCU reads the "current time buffer" data, generates a timestamp, and packages the security log together with the timestamp into a CAN message, sends it to the wireless terminal module, and finally uploads it to the cloud platform.
[0096] The gateway controller provided in this application has the following advantages: 1. Controllable cost: Using RTC timing chips eliminates the need for additional complex hardware modules, resulting in low implementation costs. Furthermore, RTC timing chips can be selectively mounted on the circuit board hardware during production, based on specific requirements, enabling precise cost control.
[0097] 2. High adaptability and flexibility: Through UDS diagnostics, configuration words can be written to achieve flexible switching of time source when the vehicle rolls off the production line, without the need to modify hardware or re-burn software. It can be adapted to vehicle configurations without wireless terminal modules, reducing the development cost of model differentiation and shortening the R&D cycle.
[0098] 3. Excellent ease of maintenance: Initial time setting and configuration parameter reading are all completed through UDS diagnostics, without the need to disassemble the gateway controller, reducing the difficulty of later maintenance; at the same time, it supports time status feedback, and later maintenance personnel can use UDS diagnostics to check the internal timing of the gateway and perform calibration.
[0099] 4. High time reliability: It adopts an external RTC timing chip and an external crystal oscillator, and the timing accuracy is less than 7s / 24h.
[0100] 5. Strong regulatory compliance: Fully meets the requirements of GB44495 for security log timestamps. The time source can be selected according to the configuration to adapt to different vehicle models and all meet the regulatory requirements for security logs.
[0101] This application also provides a vehicle that includes the gateway controller provided in any of the foregoing embodiments.
[0102] In this embodiment, the vehicle includes the gateway controller provided in any of the foregoing embodiments, thereby enabling vehicles of different models or configurations to be configured with the gateway controller provided in this application embodiment. In practical application scenarios, only the time source configuration information needs to be configured based on the actual requirements of the vehicle model. Therefore, the vehicle provided in this application embodiment can effectively control the cost of developing software and hardware.
[0103] The embodiments of this application also need to be explained as follows: (1) The accompanying drawings corresponding to the embodiments of this application only involve the structures involved in the embodiments of this application. Other structures can be referred to the general design.
[0104] (2) For clarity, the thickness of layers or regions is enlarged or reduced in the drawings used to describe embodiments of this application, i.e., these drawings are not drawn to actual scale. It is understood that when an element such as a layer, film, region or substrate is referred to as being "above" or "below" another element, the element may be "directly" located "above" or "below" the other element or there may be intermediate elements.
[0105] (3) Where there is no conflict, the embodiments of this application and the features in the embodiments can be combined with each other to obtain new embodiments. The new embodiments still fall within the scope of disclosure of the embodiments of this application, and the new embodiments can provide a basis for the protection scope that this application wants to achieve.
[0106] (4) For the same or similar parts between the various embodiments or implementations in this specification, please refer to each other. In particular, for the device embodiments and terminal embodiments, since they are basically similar to the method embodiments or implementations, the description is relatively simple, and the relevant parts can be referred to the description in the method embodiments.
[0107] The above description is merely a specific implementation of the embodiments of this application, but the protection scope of the embodiments of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the protection scope of the embodiments of this application.
Claims
1. A method for determining a time source, characterized in that, include: Obtain time source configuration information; Based on the time source configuration information, determine the target time source from at least two time sources; Time information is generated based on the target time source.
2. The method according to claim 1, characterized in that, The at least two time sources include: a time source based on time messages and a time source based on clock chips.
3. The method according to claim 2, characterized in that, The time configuration information to be obtained includes: Read time source configuration information; Based on successfully reading the time source configuration information, execute "Based on the time source configuration information, determine the target time source from at least two time sources"; If the time source configuration information fails to be read, configure the time source configuration information and jump to "Read Time Source Configuration Information".
4. The method according to claim 2, characterized in that, The determination of the target time source from at least two time sources based on time source configuration information includes: Based on the time source configuration information as the first time source configuration information, the time source based on the time message is determined as the target time source; Based on the time source configuration information as the second time source configuration information, the time source based on the clock chip is determined as the target time source.
5. The method according to claim 3, characterized in that, The target time source is the time source based on the time message, and the generation of time information based on the target time source includes: Obtain the time message and generate time information based on the time message.
6. The method according to claim 3, characterized in that, The target time source is a time source based on a clock chip, and the generation of time information based on the target time source includes: Configure initial time; Based on the initial time, the clock chip is activated to start timing and generate time information.
7. The method according to any one of claims 1-6, characterized in that, Also includes: The system periodically acquires time information and generates timestamp information based on the last acquired time information when a security event is detected, so that the security log information can be embedded with the timestamp information.
8. A gateway controller, characterized in that, The time source of the gateway controller is determined by the method described in any one of claims 1-7.
9. The gateway controller according to claim 8, characterized in that, include: microprocessor; The clock chip is electrically connected to the microprocessor; A first memory is electrically connected to the microprocessor. The first memory is used to store time source configuration information. The microprocessor is used to determine a target time source from at least two time sources based on the time source configuration information. A first power source is electrically connected to the microprocessor.
10. A vehicle, characterized in that, Includes a gateway controller, the time source of which is determined by the method of any one of claims 1-7, and / or, the gateway controller is the gateway controller of claim 8 or 9.