Communication method, device and controller

By converting the access request of the virtual machine into Hypervisor request in the automotive electronic system, the problem of restricted communication between virtual machines is solved, and SWC access to data outside the virtual machine is realized, which improves the communication range and real-timeness, and enhances the System compatibility and security.

CN118890239APending Publication Date: 2024-11-01上海适宇智能科技有限公司
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410916057.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-09
Publication Date
2024-11-01

AI Technical Summary

Technical Problem

Virtual Machine Software Components (SWCs) in automotive electronic systems cannot access external data of virtual machines after moving between virtual machines, resulting in limited communication.

Method used

The SWC access request is converted into Hypervisor's communication request through a virtual machine, and the Hypervisor finds and forwards the corresponding access data, allowing the SWC to access external data of the virtual machine, and uses a lightweight virtualization compatibility layer to replace traditional full virtualization mounting , provides efficient communication mechanisms, and implements data isolation and security through Hypervisor.

Benefits of technology

It improves the communication range and real-time nature of SWCs in virtual machines, reduces virtualization overhead, supports the coexistence of functional components with different security and real-time requirements, simplifies code adaptation and porting, and enhances system compatibility and security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118890239A_ABST
    Figure CN118890239A_ABST
Patent Text Reader

Abstract

The invention provides a communication method and device and a controller, and the method comprises the steps: converting an access request of a software component SWC for a runtime environment RTE into a communication request of Hypervisor through a virtual machine, and enabling the SWC to run in the virtual machine; and searching for access data corresponding to the communication request through the Hypervisor, and copying the access data to a memory region accessible by the SWC. An access request of a software component SWC for a runtime environment RTE is converted into a communication request of a Hypervisor through a virtual machine, and access data corresponding to the communication request is found through the Hypervisor and forwarded to the SWC, so that the access request of the SWC for the RTE is completed by using the virtual machine and the Hypervisor, SWC communication in the virtual machine is not limited any more, and the communication range of the SWC in the virtual machine is widened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of automotive electronics and hardware virtualization, and in particular to a communication method, device and controller. Background Art

[0002] At present, the controller in the automotive electronic system is usually used as the key control unit of the vehicle. The controller usually runs the Run Time Environment (RTE) and virtual machine of the AUTOSAR architecture. The RTE provides various signal read and write services for the software components (SWC) running in the virtual machine. In the specific practice process, it is found that the signal read and write services provided by the RTE are provided in the form of a virtual function bus (VFB), which will limit the communication of the SWC in the virtual machine. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a communication method, device and controller for improving the problem of limited SWC communication in a virtual machine.

[0004] The embodiment of the present application provides a communication method, which is applied to a controller, on which a virtual machine and an operating system are running, and on which a management program Hypervisor of the virtual machine is running. The communication method includes: converting the access request of the software component SWC for the runtime environment RTE into a communication request of the Hypervisor through the virtual machine, and the SWC runs in the virtual machine; searching for the access data corresponding to the communication request through the Hypervisor, and copying the access data to the memory area accessible to the SWC. In the implementation process of the above scheme, the access request of the software component SWC for the runtime environment RTE is converted into a communication request of the Hypervisor through the virtual machine, and the access data corresponding to the communication request is found through the Hypervisor and forwarded to the SWC, thereby completing the access request of the SWC to the RTE using the virtual machine and the Hypervisor, improving the situation that the SWC can no longer access the data outside the virtual machine where the SWC is located after being moved into the virtual machine, effectively allowing the SWC to access the data outside the virtual machine where it is located, so that the SWC communication in the virtual machine is no longer restricted, thereby improving the communication range of the SWC in the virtual machine.

[0005] Furthermore, compared with the traditional fully virtualized virtual machine with AUTOSAR components mounted, the virtual machine of the above solution no longer mounts AUTOSAR components (such as BSW components, RTE components or operating system OS components, etc.), but is replaced by a lightweight virtualization compatibility layer for converting SWC's access request to RTE into Hypervisor's communication request. The lightweight virtualization compatibility layer can provide an efficient communication mechanism between SWC and the virtualization environment (such as access to the runtime environment RTE), thereby effectively reducing the virtualization overhead and improving the real-time communication capability after virtualization.

[0006] Furthermore, since the virtual machine hypervisor of the above solution provides an emphasized isolation mechanism for virtual machines, it allows functional components with different security and real-time requirements to coexist on the same hardware platform, effectively integrating functional components with different security and real-time requirements into the same system, thereby improving the overall compatibility and integration performance of the system.

[0007] Furthermore, since the virtual machine management program Hypervisor of the above solution can directly make a small modification and change to the existing AUTOSAR code, it can complete the function of the above lightweight virtualization compatibility layer and realize the function of adapting to lightweight virtualization, and the porting work can be completed after a small modification and change (almost 0) of the virtual machine code, which effectively protects the code that has been put into production, provides very good support for old technologies, and improves the compatibility and robustness of the above solution.

[0008] Optionally, in an embodiment of the present application, the communication request includes: Hypercall; converting the access request of the software component SWC to the runtime environment RTE into a communication request of the Hypervisor through the virtual machine, including: in the RTE wrapper in the virtual machine, converting the access request of the SWC to the RTE into a Hypercall. In the implementation process of the above scheme, the virtual machine realizes the efficient bridging of the interaction mode between the software component SWC and the runtime environment RTE, and completes the automatic conversion process from the original access of the SWC to the RTE to the communication request for the Hypervisor in the virtual environment with the help of the RTE wrapper, thereby strengthening the isolation and security between the system layers.

[0009] Optionally, in an embodiment of the present application, searching for access data corresponding to a communication request through a Hypervisor includes: parsing an identifier from a communication request through a Hypervisor, the identifier including: a variable name, a variable address, or an index ID of a variable address; retrieving access data corresponding to a Hypercall from an RTE through a Hypervisor according to the variable name, the variable address, or the index ID of the variable address. In the implementation process of the above scheme, the Hypervisor intelligently parses identifiers in communication requests, including variable names, variable addresses, or their index IDs, thereby realizing an efficient data access mechanism, directly utilizing variable identifiers (such as variable names, variable addresses, or index IDs of variable addresses), so that the system can dynamically and accurately locate target data without having to know complex memory layouts or fixed addresses in advance, thereby improving the flexibility and accuracy of cross-virtual machine boundary interactions.

[0010] Optionally, in an embodiment of the present application, before searching for access data corresponding to a communication request through the Hypervisor, it also includes: storing the Hypercall in a memory area shared by the Hypervisor and the SWC through the virtual machine; obtaining the Hypercall from the memory area through the Hypervisor by a polling mechanism or an interrupt mechanism; searching for access data corresponding to the communication request through the Hypervisor, including: if the Hypervisor obtains the Hypercall from the memory area, searching for access data corresponding to the communication request. In the implementation process of the above scheme, an efficient and flexible communication mechanism is realized by storing the Hypercall instruction in a memory area shared with the Hypervisor and the SWC, and the Hypervisor ensures the immediate processing of the Hypercall request by using polling or interrupt mechanisms, and can maintain efficient data interaction regardless of high load or low activity, thereby enhancing the adaptability and dynamics of the system.

[0011] Optionally, in an embodiment of the present application, before searching for access data corresponding to a communication request through the Hypervisor, it also includes: registering the communication service created by the Hypervisor as a virtual device in the operating system; searching for access data corresponding to the communication request through the Hypervisor, including: if the virtual device is turned on and a read operation corresponding to the communication request is detected, searching for access data corresponding to the communication request. In the implementation process of the above scheme, the service is exposed as a virtual device in the system through the virtual machine management program Hypervisor, so that the SWC can interact with the virtual machine management program Hypervisor by performing standard I / O operations (read, write, etc.) on the virtual device, effectively providing a unified and abstract interface for the SWC, so that the SWC does not need to understand the specific details or complexity of the underlying hardware. This abstraction greatly simplifies software development and maintenance work, because the SWC can perform I / O operations on the virtual device like operating a physical device, while enhancing the isolation of the system, and the operations between different SWCs will not interfere with each other, improving the stability and security of the system.

[0012] Optionally, in an embodiment of the present application, the communication request includes: a trigger request sent by the virtual machine to the Hypervisor through the Trap mechanism; the access request of the software component SWC to the runtime environment RTE is converted into a communication request of the Hypervisor through the virtual machine, including: judging whether the virtual machine where the SWC is located executes a preset instruction through the processor on the controller; if so, suspending the operation of the virtual machine, and converting the access request of the software component SWC to the runtime environment RTE through the Hypervisor into a trigger request sent by the virtual machine to the Hypervisor through the Trap mechanism. In the implementation process of the above scheme, by introducing a processor monitoring mechanism at the controller level to intelligently judge the execution status of the SWC in the virtual machine, once it is detected that the SWC is executing a specific preset instruction, the controller quickly intervenes, suspends the operation of the relevant virtual machine, and converts the access request of the RTE into a trigger request sent by the virtual machine to the Hypervisor through the Trap mechanism. This real-time monitoring and intervention capability significantly enhances the system's response speed to abnormal or potential risk instructions, effectively prevents the impact of illegal or unexpected operations on system stability, and improves overall security.

[0013] Optionally, in an embodiment of the present application, before converting the access request of the software component SWC to the runtime environment RTE into a communication request of the Hypervisor through the virtual machine, it also includes: generating a virtual machine and an executable file of the virtual machine corresponding to the SWC, and the function of the executable file includes: converting the access request of the SWC to the RTE into a communication request of the Hypervisor. In the implementation process of the above scheme, by generating a specific executable file for each SWC, the mode and authority of its interaction with the RTE can be accurately controlled, and a more detailed security policy configuration can be achieved, thereby enhancing the security of the system. Moreover, the customized executable file specifically handles the request conversion of the SWC, which can reduce unnecessary processing steps and resource consumption compared to the general solution, and improve the speed of request processing and the overall performance of the system.

[0014] Optionally, in an embodiment of the present application, generating a virtual machine and an executable file of a SWC corresponding to the virtual machine includes: obtaining a SWC definition file and a SWC code through a SWC editing tool; obtaining an RTE definition file, and configuring and compiling and assembling the RTE definition file and the SWC definition file to obtain an assembly file of the RTE; obtaining a definition file of the virtual machine, and configuring and compiling and assembling the definition file of the virtual machine to obtain an assembly file of the virtual environment; compiling and assembling the SWC code to obtain an assembly file of the SWC; statically linking the assembly file of the RTE, the assembly file of the virtual environment, and the assembly file of the SWC to obtain an executable file. In the implementation process of the above scheme, by statically linking the assembly file of the RTE, the assembly file of the virtual environment, and the assembly file of the SWC, the overhead of the virtual machine at runtime can be minimized, and an executable file for SWC to access the runtime environment RTE (i.e., SWC's access request to the runtime environment RTE) can be obtained.

[0015] Optionally, in an embodiment of the present application, the RTE definition file and the SWC definition file are configured and compiled, including: obtaining a static scheduling table, the static scheduling table including: at least one static scheduling rule; configuring and compiling the RTE definition file and the SWC definition file according to the scheduling rule. In the implementation process of the above scheme, the RTE definition file and the SWC definition file are configured and compiled according to the scheduling rules in the static scheduling table, so that the system realizes the static scheduling function, thereby effectively reducing the operating overhead of the entire system and improving the operating efficiency of the controller.

[0016] Optionally, in an embodiment of the present application, access data is copied to a memory area accessible to SWC, including: copying the access data to a shared memory or message queue managed by the Hypervisor through the Hypervisor, and the access data in the shared memory or message queue is used to be read by the SWC. In the implementation process of the above scheme, the access data is copied to a shared memory or message queue managed by the Hypervisor through the Hypervisor, and is read by the SWC, so that the shared memory and message queue are used as a high-speed inter-process communication mechanism, which can significantly reduce data transmission delays and improve system response speed compared to other communication methods (such as sockets, pipes, etc.). Hypervisor directly intervenes in data replication to ensure the efficiency and timeliness of data transmission.

[0017] Optionally, in an embodiment of the present application, shared memory or message queues are shared between SWCs in different virtual machines; and / or, shared memory or message queues are shared between SWCs in a virtual machine and SWCs running on an operating system; and / or, shared memory or message queues are shared between SWCs in a virtual machine and basic software BSW, and BSW runs in a virtual machine or on an operating system. In the implementation process of the above scheme, by setting shared memory or message queues, SWCs in different virtual machines are allowed to share access to data to implement a communication mechanism, so that even if the software component (SWC) is moved to another virtual machine, the SWC can access data outside the virtual machine where the SWC is located, and the communication of the SWC is no longer restricted, thereby improving the communication range of the SWC in the virtual machine. Not only that, by setting shared memory or message queues, it is also possible to realize mutual communication between the SWC in the virtual machine and the SWC running on the operating system, and to realize mutual communication between the SWC in the virtual machine and the basic software BSW.

[0018] Optionally, in an embodiment of the present application, it also includes: the Hypervisor allocates an independent virtual memory space to each virtual machine in the shared memory or message queue; the virtual memory spaces corresponding to different virtual machines in the shared memory or message queue are isolated from each other through a protection mechanism to ensure that each virtual machine can only access its allocated virtual memory space, and the protection mechanism includes: a hardware memory protection mechanism and / or a software memory protection mechanism. In the implementation process of the above scheme, the Hypervisor allocates an independent virtual memory space to each virtual machine in the shared memory or message queue, and the virtual memory spaces corresponding to different virtual machines in the shared memory or message queue are isolated from each other through a protection mechanism, so that the accessible memory spaces of different virtual machines are isolated from each other, and the accessible memory space is isolated from the code of the virtual machine management program Hypervisor, which effectively increases the security of the Hypervisor and each virtual machine.

[0019] Optionally, in an embodiment of the present application, the Hypervisor runs as a system component on the operating system, and the Hypervisor is used to manage virtual machines. In the implementation process of the above solution, the duplicate creation of the operating system and the underlying components is reduced, the resource usage and startup time are reduced, thereby improving the overall performance of the system, and since the Hypervisor runs as a system component of the operating system, it can be managed and maintained in a unified manner, reducing maintenance costs and complexity. Since the Hypervisor provides isolation between virtual machines, the security of the system is enhanced. Even if a virtual machine is attacked, other virtual machines and the host system can remain safe, thereby enhancing the overall security of the system.

[0020] An embodiment of the present application also provides a communication device, which is applied to a controller, where a virtual machine and an operating system are running on the controller, and a management program Hypervisor of the virtual machine is running on the operating system. The communication device includes: a communication request conversion module, which is used to convert an access request of a software component SWC to a runtime environment RTE into a communication request of the Hypervisor, and the SWC runs in the virtual machine; a data search and forwarding module, which is used to search for access data corresponding to the communication request and copy the access data to a memory area accessible to the SWC.

[0021] Optionally, in an embodiment of the present application, the communication request includes: a Hypercall; a communication request conversion module, including: an access request conversion submodule, used to convert the access request of the SWC to the RTE into a Hypercall in the RTE wrapper in the virtual machine.

[0022] Optionally, in an embodiment of the present application, the data search and forwarding module includes: a communication request parsing submodule, which is used to parse an identifier from a communication request through a Hypervisor, where the identifier includes: a variable name, a variable address, or an index ID of a variable address; an access data retrieval submodule, which is used to retrieve access data corresponding to the Hypercall from the RTE through the Hypervisor according to the variable name, the variable address, or the index ID of the variable address.

[0023] Optionally, in an embodiment of the present application, the communication device further includes: a Hypercall storage module, used to store the Hypercall in a memory area shared by the Hypervisor and the SWC through a virtual machine; a Hypercall acquisition module, used to acquire the Hypercall from the memory area through the Hypervisor using a polling mechanism or an interrupt mechanism; and a first data search module, used to search for access data corresponding to the communication request if the Hypervisor acquires the Hypercall from the memory area.

[0024] Optionally, in an embodiment of the present application, the communication device also includes: a virtual device registration module, used to register the communication service created by the Hypervisor as a virtual device in the operating system; a second data search module, used to search for access data corresponding to the communication request if the virtual device is opened and a read operation corresponding to the communication request is detected.

[0025] Optionally, in an embodiment of the present application, the communication request includes: a trigger request issued by the virtual machine to the Hypervisor through the Trap mechanism; a communication request conversion module, including: an instruction execution judgment submodule, used to determine whether the virtual machine where the SWC is located executes preset instructions through the processor on the controller; a communication request conversion submodule, used to suspend the operation of the virtual machine if the virtual machine where the SWC is located executes preset instructions, and convert the access request of the software component SWC to the runtime environment RTE through the Hypervisor into a trigger request issued by the virtual machine to the Hypervisor through the Trap mechanism.

[0026] Optionally, in an embodiment of the present application, the communication device further includes: an executable file generation module, used to generate an executable file of a virtual machine and a SWC corresponding to the virtual machine, and the functions of the executable file include: converting an access request of the SWC to the RTE into a communication request of the Hypervisor.

[0027] Optionally, in an embodiment of the present application, the execution file generation module includes: a file code acquisition sub-module, which is used to obtain a SWC definition file and a SWC code through a SWC editing tool; a configuration code and assembly file acquisition sub-module, which is used to obtain an RTE definition file, and configure and compile and assemble the RTE definition file and the SWC definition file to obtain an RTE assembly file; a configuration compilation and assembly sub-module, which is used to obtain a virtual machine definition file, and configure and compile and assemble the virtual machine definition file to obtain an assembly file of the virtual machine; a SWC assembly file acquisition sub-module, which is used to compile and assemble the SWC code to obtain an SWC assembly file; and an assembly static link sub-module, which is used to statically link the RTE assembly file, the virtual machine assembly file, and the SWC assembly file to obtain an executable file.

[0028] Optionally, in an embodiment of the present application, the configuration code and assembly file acquisition sub-module includes: a scheduling rule parsing unit, used to obtain a static scheduling table, the static scheduling table includes: at least one static scheduling rule; a definition file compilation unit, used to configure and compile the RTE definition file and SWC definition file according to the scheduling rules.

[0029] Optionally, in an embodiment of the present application, the data search and forwarding module includes: an access data replication submodule, which is used to copy the access data to a shared memory or message queue managed by the Hypervisor through the Hypervisor, and the access data in the shared memory or message queue is used to be read by the SWC.

[0030] Optionally, in an embodiment of the present application, shared memory or message queues are shared between SWCs in different virtual machines; and / or, shared memory or message queues are shared between SWCs in a virtual machine and SWCs running on an operating system; and / or, shared memory or message queues are shared between SWCs in a virtual machine and basic software BSW, and BSW runs in a virtual machine or on an operating system.

[0031] Optionally, in an embodiment of the present application, the communication device further includes: a memory space allocation module, which is used for the Hypervisor to allocate independent virtual memory space to each virtual machine in the shared memory or message queue; a memory space isolation module, which is used to isolate the virtual memory spaces corresponding to different virtual machines in the shared memory or message queue from each other through a protection mechanism, and the protection mechanism includes: a hardware memory protection mechanism and / or a software memory protection mechanism. Optionally, in an embodiment of the present application, the Hypervisor runs as a system component on the operating system, and the Hypervisor is used to manage virtual machines.

[0032] An embodiment of the present application further provides a controller, including: a processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the machine-readable instructions execute the method described above when executed by the processor.

[0033] An embodiment of the present application also provides a vehicle, which includes: a vehicle body and the controller described above, and the controller is used to control the operation of the vehicle body.

[0034] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described above is executed.

[0035] The embodiment of the present application also provides a computer program product, including: a computer program or a computer instruction, and the computer program or the computer instruction executes the method described above when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0037] Figure 1 A flow chart of a communication method provided in an embodiment of the present application is shown;

[0038] Figure 2 A schematic diagram of the system architecture of a controller provided in an embodiment of the present application is shown;

[0039] Figure 3 A schematic diagram of a process for generating an executable file provided in an embodiment of the present application is shown;

[0040] Figure 4 A schematic diagram of a flow chart of a communication device provided in an embodiment of the present application is shown;

[0041] Figure 5 A schematic diagram of the structure of a controller provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0042] To make the purpose, technical scheme and advantages of the embodiment of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. It should be understood that the drawings in the embodiment of the present application only serve the purpose of explanation and description, and are not used to limit the protection scope of the embodiment of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in the embodiment of the present application shows the operation implemented according to some embodiments of the embodiment of the present application. It should be understood that the operation of the flowchart can be implemented out of order, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the embodiment of the present application, or remove one or more operations from the flowchart.

[0043] It is understandable that the "first" and "second" in the embodiments of the present application are used to distinguish similar objects. Those skilled in the art will understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not necessarily limit the difference. In the description of the embodiments of the present application, the term "and / or" is merely a description of the association relationship of associated objects, indicating that there may be three relationships, such as A and / or B, which can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the related objects before and after are in an "or" relationship. The term "multiple" refers to more than two (including two), and similarly, "multiple groups" refers to more than two groups (including two groups).

[0044] Before introducing the communication method provided in the embodiment of the present application, some concepts involved in the embodiment of the present application are first introduced:

[0045] AUTOSAR (AUTomotive Open System ARchitecture, AUTOSAR) is a standardized software framework and open electrical / electronic (E / E) system architecture for intelligent mobility.

[0046] A controller is an electronic device or electromechanical device whose main responsibility is to receive and process signals from the outside or inside, and output control instructions to the actuator according to preset logic, algorithms or programs. The controller can be used to adjust, drive or manage the operating status, actions or outputs of one or more systems, machines, and processes. In automotive electronic systems, the controller types using the AUTOSAR architecture include: Engine Control Unit (ECU), Transmission Control Unit (TCU), etc. Among them, ECU is used to control various functions of the vehicle, such as engine control, transmission control, brake system control, etc., and TCU is used to control the shifting logic of the automatic transmission to improve driving comfort and fuel economy.

[0047] In the related art, the controller in the automotive electronic system usually runs the runtime environment (RTE) and virtual machine of the AUTOSAR architecture. The signal reading and writing services provided by the RTE are provided in the form of a virtual function bus (VFB). When a software component (SWC) is moved into another virtual machine, it can no longer access the memory and address outside the virtual machine where the SWC is located. Therefore, the SWC cannot access the data stored in the memory or address outside the virtual machine where the SWC is located, resulting in the communication of the SWC being restricted.

[0048] After long-term research and analysis, it is found that when a software component (SWC) moves between virtual machines, the ability of SWC to directly access data in other virtual machines is limited. The reason is that virtualization technology is essentially to achieve resource isolation and security boundaries, ensuring that multiple software components (SWCs) in each virtual machine run independently and do not interfere with each other. Therefore, once a software component (SWC) is moved to another virtual machine, it can no longer access data outside the virtual machine where the SWC is located. Virtualization technology manages each virtual machine through a virtual machine monitor (Hypervisor or Virtual Machine Monitor, VMM), ensuring that each virtual machine has independent memory space, CPU time slices and other hardware resources, which means that SWCs cannot directly share memory or hardware resources between different virtual machines.

[0049] In view of the above problems, in order to overcome this limitation, the embodiment of the present application converts the access request of the software component SWC to the runtime environment RTE into a communication request of the Hypervisor through the virtual machine, and forwards the access data corresponding to the communication request to the SWC through the Hypervisor, so that the SWC can continue to work in the virtual environment corresponding to the new virtual machine. The embodiment of the present application forms a new communication mechanism by improving the execution actions of the virtual machine and the execution actions of the Hypervisor. This communication mechanism can effectively realize the communication of SWCs between virtual machines, so that even if the software component (SWC) is moved into other virtual machines, the communication of the SWC is no longer restricted, thereby improving the communication range of the SWC in the virtual machine.

[0050] See also Figure 1 The flow chart of the communication method provided by the embodiment of the present application is shown; the embodiment of the present application provides a communication method, which can be applied to a controller, on which a virtual machine and an operating system are running, and on which a hypervisor of the virtual machine can be running. The implementation of the above communication method may include:

[0051] Step S110: converting the access request of the software component SWC to the runtime environment RTE into a communication request of the Hypervisor through the virtual machine, and the SWC runs in the virtual machine.

[0052] See also Figure 2 The system architecture diagram of the controller provided by the embodiment of the present application is shown; it can be understood that the above communication method can be executed by the controller, which can include a microcontroller unit (MCU) or multiple microcontroller units (MCU); at least one processor core (Core) can be run on the microcontroller, and an operating system (OS) or a virtual machine (VM) can be run on the processor core (Core), and a hypervisor (Hypervisor) of the virtual machine can be run on the operating system, that is, the Hypervisor is used to manage the virtual machine, such as dynamically allocating CPU time and memory resources (such as shared memory or message queues, etc.) to the virtual machine, and scheduling the execution of the virtual machine, etc. At least one SWC can be run on the virtual machine, and these SWCs can be scheduled by the SWC scheduler (SWC scheduler), and the virtual machine is responsible for converting the access request of the software component SWC to the runtime environment RTE into a communication request (such as Hypercall or Trap) of the Hypervisor.

[0053] Step S120: searching for access data corresponding to the communication request through the Hypervisor, and copying the access data to a memory area accessible to the SWC.

[0054] It is understandable that the above-mentioned virtual machine can be created and initialized by the Hypervisor according to its configuration. The Hypervisor can abstract and virtualize the call of the SWC to access the input and output (I / O) device, and can also provide shared access and device simulation services for each SWC, so as to provide complete RTE access support for one or more SWCs running under each virtual machine. The SWC in the virtual machine can complete the RTE call operation through the access request, and the target object communicating with the SWC can be running on other virtual machines (i.e., a virtual machine different from the SWC), or it can run in the above-mentioned operating system. The target object here includes but is not limited to the basic software (Basic Soft Ware, BSW) in the SWC or AUTOSAR architecture, etc., and BSW is for example: Controller Area Network (Controller Area Network, CAN) module, CanIf module, Eth module, EthIf module, etc.

[0055] In the process of implementing the above scheme, the access request of the software component SWC to the runtime environment RTE is converted into a communication request of the Hypervisor through the virtual machine, and the access data corresponding to the communication request is found through the Hypervisor and forwarded to the SWC, so that the access request of SWC to RTE is completed by using the virtual machine and the Hypervisor, which improves the situation that the SWC can no longer access the data outside the virtual machine where the SWC is located after being moved into the virtual machine, effectively allows the SWC to access the data outside the virtual machine where it is located, so that the communication of the SWC in the virtual machine is no longer restricted, thereby improving the communication range of the SWC in the virtual machine.

[0056] Furthermore, compared with the traditional fully virtualized virtual machine with AUTOSAR components mounted, the virtual machine of the above solution no longer mounts AUTOSAR components (such as BSW, RTE or operating system OS components, etc.), but is replaced by a lightweight virtualization compatibility layer for converting the access request of the software component SWC to the RTE into a communication request of the Hypervisor. The lightweight virtualization compatibility layer can provide an efficient communication mechanism between the SWC and the virtualization environment (such as access to the runtime environment RTE), thereby effectively reducing the virtualization overhead and improving the real-time communication capability after virtualization.

[0057] Furthermore, since the virtual machine hypervisor of the above solution provides an emphasized isolation mechanism for virtual machines, it allows functional components with different security and real-time requirements to coexist on the same hardware platform, effectively integrating functional components with different security and real-time requirements into the same system, thereby improving the overall compatibility and integration performance of the system.

[0058] Furthermore, since the virtual machine management program Hypervisor of the above solution can directly make a small modification and change to the existing AUTOSAR code, it can complete the function of the above lightweight virtualization compatibility layer and realize the function of adapting to lightweight virtualization, and the porting work can be completed after a small modification and change (almost 0) of the virtual machine code, which effectively protects the code that has been put into production, provides very good support for old technologies, and improves the compatibility and robustness of the above solution.

[0059] Optionally, before searching for access data corresponding to the communication request through the Hypervisor, the operating system can be started and initialized first, and then the hypervisor of the virtual machine can be run. For example, the operating system initializes the kernel, core services (such as task scheduler and memory management service) and hardware, and then the operating system loads the configuration file of the Hypervisor, and initializes and runs the Hypervisor service and its code. After the Hypervisor is running, it can do other tasks such as enabling CPU virtualization, etc. In the implementation process of the above scheme, the hypervisor of the virtual machine provides a powerful isolation mechanism for the virtual machine, thereby protecting the virtual machine or key components from interference from other unimportant components, or reducing the probability of the virtual machine or key components being attacked by other faulty components, effectively improving the security of the controller virtualization. Furthermore, the hypervisor of the virtual machine can isolate the software component SWC in the virtual machine, thereby limiting the scope of influence of the infected component or faulty component of the SWC (also known as the fault domain), effectively preventing these infected components or faulty components from unauthorized access to sensitive resources of the system, thereby improving the security of the overall system.

[0060] As an optional implementation of the above step S110, the above communication request may include: Hypercall; this implementation may include: in the RTE wrapper in the virtual machine, converting the access request of the SWC to the RTE into a Hypercall, and the specific details will be described in detail below.

[0061] The above-mentioned implementation method of converting the access request of the software component SWC to the RTE into the communication request of the Hypervisor may include:

[0062] Step S111: determining, through the virtual machine, whether the service interface function of the RTE is triggered.

[0063] The pseudo code of the service interface function of the above RTE is as follows: status = Rte_Read_VehicleSpeed ​​(&speedValue); This service interface function example represents a standard way for a software component (SWC) to access external data of the virtual machine through the Runtime Environment (RTE). The function of this function is to read the current vehicle speed information from the communication network inside the vehicle (such as the controller area network CAN) and store its value in the speedValue variable. When the service interface function Rte_Read_VehicleSpeed ​​(&speedValue) is triggered, the software component (SWC) will request the RTE to read the current vehicle speed data from the vehicle's sensor or CAN network and write the data to the speedValue variable. After the function is executed, the status variable will contain the operation status, and the application can use it to determine whether the vehicle speed information has been successfully obtained and how to further process the data.

[0064] Step S112: If the service interface function of the RTE is triggered, the access request of the SWC to the RTE is converted into a Hypercall in the RTE wrapper in the virtual machine.

[0065] The pseudo code in the RTE wrapper in the above virtual machine is as follows:

[0066]

[0067] The RTE wrapper in the virtual machine mentioned above refers to the wrapper function obtained by decorating the service interface function of the original RTE, which triggers a system call (hypercall) sent to the virtual machine hypervisor internally. This pseudo code example shows a custom Rte_Read_VehicleSpeed ​​function implementation, which is used to obtain the value of the VehicleSpeed ​​signal through the Hypervisor system call (hypercall), thereby effectively reading the vehicle speed signal value through the Hypervisor's Hypercall mechanism and storing it in the buffer provided by the application.

[0068] Another pseudo code in the RTE wrapper in the above virtual machine is as follows:

[0069]

[0070] The RTE wrapper in the virtual machine mentioned above refers to the wrapper function obtained by decorating the service interface function of the original RTE, which will also trigger a system call (hypercall) sent to the virtual machine manager internally. This pseudo code example is used to obtain vehicle speed data from the bottom layer of the system through the Hypervisor system call (hypercall), and store the read data in the memory location provided by the caller, and return the operation status so that the caller can determine whether it is successful.

[0071] It should be noted that the above Hypervisor system call (hypercall) can be an interface function, and the specific implementation can be implemented in the internal handler function of the virtual machine management program Hypervisor, such as the following pseudo code:

[0072]

[0073] It is understandable that the "RTE VFB" in the embodiment of the present application emphasizes that the RTE component has implemented the conceptual abstract model of the virtual function bus (VFB). This way of expression actually emphasizes the specific scope of action or implementation details of the RTE, that is, RTE is a specific technical means to implement the concept of VFB. The "VFB" part of "RTE VFB" highlights the virtual function bus principle followed by RTE when processing communication and data exchange between software components. The above pseudocode defines a function called hypercall_handler, which is used to simulate the process of processing Hypercall requests. The virtual machine manager Hypervisor has a processor to distinguish different types of Hypercalls. In the automotive electronic software architecture, the process of data transmission from the virtualization layer to the application layer is simulated by utilizing a custom Hypercall mechanism to interact with the RTE.

[0074] Since the hypervisor already knows the specific location of the RTE VFB, the hypervisor can obtain the latest value of VehicleSpeed ​​from the RTE VFB. Of course, this is just one of the implementation methods. In the actual practice, it can also be implemented in the form of static address linking, such as the following pseudo code:

[0075]

[0076]

[0077] In the pseudo code above, the hypercall_handler function is a general function that handles various types of hypercall requests, among which the GET_SIGNAL type request is specially handled to obtain the latest value of a specified signal (such as VehicleSpeed) from the RTE VFB. Directly linking to the VehicleSpeed ​​signal value in the VFB through a static address usually means that the address of the signal in the VFB is known and unchanged, which requires that the memory layout of all signals is determined at system initialization and remains unchanged during the entire run. In other words, when using the static address link form to implement it, it is necessary to know the static address of the VehicleSpeed ​​signal in the RTE VFB. Before calling hypercall(GET_SIGNAL,&VehicleSpeed,sizeof(VehicleSpeed),data), make sure that &VehicleSpeed ​​does not directly point to a variable, but instead points to the exact static address of the VehicleSpeed ​​signal in the RTE VFB.

[0078] As an optional implementation of the above step S120, the implementation of searching for access data corresponding to the communication request through the Hypervisor may include:

[0079] Step S121: parsing an identifier from the communication request through the Hypervisor, where the identifier includes: a variable name, a variable address, or an index ID of a variable address.

[0080] The index ID of the variable address above is for example: a preset data address is passed in the hypercall, and the index ID of the preset data address can also be passed. Of course, a unique index ID can also be assigned to the variable address called by each virtual machine hypervisor.

[0081] Step S122: The Hypervisor retrieves access data corresponding to the Hypercall from the RTE according to the variable name, the variable address or the index ID of the variable address.

[0082] It is understandable that the above-mentioned access data has many forms, such as signal values, sensor readings or control commands, etc. The following takes the CAN bus signal as an example to illustrate the process of obtaining access data. First, the CAN bus signal originates from a physical sensor or an electronic control unit (ECU) on the vehicle network, which can encapsulate the signal value in the original CAN frame. Then, the CAN driver located in the operating system receives the original CAN frame, extracts the signal value from the original CAN frame according to the predefined signal mapping relationship, and provides the signal value to the AUTOSAR CanIf module. Finally, the AUTOSAR CanIf module stores it in the memory area of ​​the RTE that can be accessed by the Hypervisor. If the signal value is updated, the signal value in the memory area of ​​the RTE that can be accessed by the Hypervisor can also be updated in sequence along the above process.

[0083] An implementation example of the above step S122 is as follows: the Hypervisor may retrieve the access data corresponding to the Hypercall (such as the above signal value) from the memory area of ​​the RTE accessible to the Hypervisor and the SWC through a polling mechanism or an interrupt mechanism. During a specific retrieval, the access data corresponding to the Hypercall may be retrieved from the memory area according to the variable name, the variable address, or the index ID of the variable address.

[0084] In the implementation process of the above solution, the Hypervisor intelligently parses the identifiers in the communication request, including the variable name, variable address or its index ID, thereby realizing an efficient data access mechanism. The variable identifier (such as the variable name, variable address or the index ID of the variable address) is directly used, so that the system can dynamically and accurately locate the target data without knowing the complex memory layout or fixed address in advance, thereby improving the flexibility and accuracy of cross-layer data interaction.

[0085] As an optional implementation of the above method, before searching the access data corresponding to the communication request through the Hypervisor, the following may also be included:

[0086] Step S113: The Hypercall is stored in the memory area shared by the Hypervisor and the SWC through the virtual machine.

[0087] Step S114: The Hypervisor obtains the Hypercall from the memory area by a polling mechanism or an interrupt mechanism.

[0088] As an optional implementation of the above step S120, the implementation of searching for access data corresponding to the communication request through the Hypervisor may include:

[0089] Step S123: If the Hypervisor obtains the Hypercall from the memory area, it searches for access data corresponding to the communication request and copies the access data to the memory area accessible to the SWC.

[0090] It can be understood that when SWC needs to read access data (such as the signal value mentioned above), SWC obtains the access data by initiating a call (such as Hypercall). For example, when SWC in the virtual machine needs to read the signal value, it obtains the signal value by initiating a system call (Hypercall) with a target signal parameter to the virtual machine management program Hypervisor. After the Hypervisor obtains the Hypercall from the memory area shared by the Hypervisor and SWC through a polling mechanism or an interrupt mechanism, it searches for the access data corresponding to the communication request in the memory area of ​​the RTE accessible to the Hypervisor, and copies the access data to the memory area accessible to the SWC (such as the buffer provided by the SWC).

[0091] In the implementation process of the above solution, an efficient and flexible communication mechanism is realized by storing Hypercall instructions in a memory area shared with the Hypervisor and SWC (Software Component). The Hypervisor uses polling or interrupt mechanisms to ensure the immediate processing of Hypercall requests. Whether in high load or low activity, it can maintain efficient data interaction, thereby enhancing the adaptability and dynamics of the system.

[0092] As an optional implementation of the above method, before searching the access data corresponding to the communication request through the Hypervisor, the following may also be included:

[0093] Step S115: register the communication service created by the Hypervisor as a virtual device in the operating system.

[0094] As an optional implementation of the above step S120, the implementation of searching for access data corresponding to the communication request through the Hypervisor may include:

[0095] Step S124: If the virtual device is opened and a read operation corresponding to the communication request is detected, then the access data corresponding to the communication request is searched.

[0096] In the implementation process of the above solution, the service is exposed as a virtual device in the system through the virtual machine hypervisor Hypervisor, so that SWC can interact with the virtual machine hypervisor Hypervisor by performing standard I / O operations (read, write, etc.) on the virtual device, effectively providing a unified and abstract interface for SWC, so that SWC does not need to understand the specific details or complexity of the underlying hardware. This abstraction greatly simplifies software development and maintenance work, because SWC can perform I / O operations on virtual devices like operating physical devices. At the same time, it enhances the isolation of the system, and the operations between different SWCs will not interfere with each other, thereby improving the stability and security of the system.

[0097] As an optional implementation of the above step S110, the above communication request may include: a trigger request sent by the virtual machine to the Hypervisor through the Trap mechanism; the above implementation of converting the access request of the software component SWC to the runtime environment RTE into the communication request of the Hypervisor may include:

[0098] Step S116: Determine, by means of the processor on the controller, whether the virtual machine where the SWC is located executes the preset instruction.

[0099] Step S117: If the virtual machine where the SWC is located executes the preset instruction, the operation of the virtual machine is suspended, and the access request of the software component SWC to the runtime environment RTE is converted into a trigger request sent by the virtual machine to the Hypervisor through the Trap mechanism.

[0100] In the implementation process of the above solution, a processor monitoring mechanism is introduced at the controller level to intelligently determine the execution status of the software component (SWC) in the virtual machine. Once it is detected that the SWC is executing specific preset instructions, the controller quickly intervenes and suspends the operation of the relevant virtual machine. This real-time monitoring and intervention capability significantly enhances the system's response speed to abnormal or potentially risky instructions, effectively prevents illegal or unexpected operations from affecting system stability, and improves overall security.

[0101] See also Figure 3 The schematic diagram of the process of generating an executable file provided by the embodiment of the present application is shown; it is understandable that the process of generating an executable file can also be completed by the configuration tools of the hypervisor and the virtual machine, for example, generating hypercall-related code, so that the code implements the signal reading and writing function of the SWC outside the virtual machine where the SWC is located. As an optional implementation of the above method, before converting the access request of the software component SWC to the runtime environment RTE into a communication request of the hypervisor through the virtual machine, it also includes:

[0102] Step S118: Generate a virtual machine and an executable file of the SWC corresponding to the virtual machine. The functions of the executable file include: converting the access request of the SWC to the RTE into a communication request of the Hypervisor.

[0103] As an optional implementation of the above step S118, the above implementation of generating a virtual machine and an executable file of a SWC corresponding to the virtual machine may include:

[0104] Step S118a: Obtain the SWC definition file and SWC code through the SWC editing tool.

[0105] The above-mentioned SWC editing tool can adopt a Rust-based SWC compiler, or a development environment or plug-in related to the compiler, such as an integrated development environment for configuring, running or debugging the SWC compilation process. The above-mentioned SWC editing tool can also adopt an AUTOSAR development tool or IDE plug-in that helps developers design, implement, configure and test AUTOSAR SWCs, such as Vector's DaVinci Developer or ETAS' INTECRIO.

[0106] Step S118b: Obtain the RTE definition file, and configure and compile the RTE definition file and the SWC definition file to obtain the RTE assembly file.

[0107] Step S118c: Obtain the definition file of the virtual machine, and configure and compile the definition file of the virtual machine to obtain the assembly file of the virtual machine.

[0108] Step S118d: compile and assemble the SWC code to obtain an assembly file of the SWC.

[0109] Step S118e: statically link the assembly file of the RTE, the assembly file of the virtual machine, and the assembly file of the SWC to obtain an executable file.

[0110] In the implementation process of the above solution, by statically linking the assembly files of RTE, the assembly files of the virtual machine and the assembly files of SWC, the overhead of the virtual machine at runtime can be minimized, and an executable file for SWC to access the runtime environment RTE (i.e., SWC's access request to the runtime environment RTE) can be obtained.

[0111] As an optional implementation of the above step S118b, the above implementation of configuring and compiling the RTE definition file and the SWC definition file may include:

[0112] Step S118f: Obtain a static scheduling table, where the static scheduling table includes: at least one static scheduling rule.

[0113] It is understandable that the above static dispatch table can be parsed from the configuration code or configuration file of the virtual machine. Of course, in addition to the static dispatch table, the configuration code or configuration file of the above virtual machine can also include: the data type, port and dependency relationship of each SWC or BSW, the data type can be the name, structure and data size of any signal or data element read or written by the SWC, the port can be a read port (R-Port) and a write port (P-Port), etc., and the dependency relationship can be a relationship that identifies whether the SWC depends on the data provided by other SWCs or BSWs in the system.

[0114] For example, the implementation method of the above step S118f is as follows: the format of the configuration code or configuration file of the above virtual machine can be in XML format, then the static scheduling table can be parsed from the configuration code or configuration file of the virtual machine through an ARXML (i.e., the abbreviation of AUTOSAR XML) parser, and the static scheduling table includes: at least one static scheduling rule. Similarly, the format of the configuration code or configuration file of the above virtual machine can also be presented in the form of structure data of C language or in code such as header file. In particular, under the AUTOSAR architecture, all configurations are embodied in the form of structure data of C language, header file of C language, etc. In this case, the configuration is presented in code, so it is called the configuration code of the virtual machine. In this case, a custom-written parser can be used to parse the static scheduling table from the configuration code of the virtual machine.

[0115] Step S118g: configure and compile the RTE definition file and the SWC definition file according to the scheduling rules.

[0116] In the implementation process of the above solution, compared with the traditional dynamic scheduling, which will increase the operating overhead and development difficulty of the entire system, in embedded scenarios such as controllers in automotive electronic systems, the basic services and middleware used by the SWC in the controller can be analyzed and calculated before mass production, so in this scenario, dynamic scheduling can be replaced by static scheduling. Therefore, this solution configures and compiles the RTE definition file and SWC definition file through the scheduling rules in the static scheduling table, so that the system can realize the static scheduling function, thereby effectively reducing the operating overhead of the entire system and improving the operating efficiency of the controller.

[0117] Optionally, before compiling the RTE definition file and the SWC definition file according to the scheduling rules, a wrapper function can also be created for the access request of the RTE in each SWC, where "RTE access request" refers to the process by which SWCs access (read or write) external data or services connected through the RTE port by calling the interface provided by the RTE (i.e., wrapper function or Port Interface Functions). The above-mentioned RTE ports are interface points defined in the AUTOSAR architecture, which allow data exchange between software components (SWCs) or between SWCs and external entities (such as hardware, operating system services). RTE ports include read ports (R-Ports) and write ports (P-Ports), which are used for data acquisition and sending, respectively. These created wrapper functions will eventually trigger a system call (hypercall), and the pseudo code of this process is as follows:

[0118]

[0119] It can be understood that the above pseudo code defines a function VehicleSpeed_Rte_Read, whose purpose is to read the current value of the VehicleSpeed ​​signal from the RTE (Runtime Environment) and store this value in the structure pointer provided by the caller. The above VehicleSpeedStoragePlace can be generated by the generation tool as a storage entity for various signals in the RTE VFB. Among them, the "VFB" part in the "RTE VFB" highlights the virtual function bus principle followed by the RTE when handling communication and data exchange between software components. In other words, the "RTE" provides actual operation support, and the "VFB" is the logical architecture concept behind this support.

[0120] The following is the generated pseudo code for the signal storage entity of the global RTE VFB:

[0121]

[0122] The above list_of_bsw_signals and list_of_swc_signals represent the BSW (Basic Software) signal list and SWC (Software Component) signal list parsed from the ARXML file, respectively. BSW usually refers to the basic software module of the ECU, while SWC represents the software component that implements a specific function. These two lists constitute the original source of ECU signals. After using the custom combine function to merge the two signal lists into a new list all_vfb_signals, the remove_duplicates function is used to remove duplicate items in the merged list to ensure that each signal appears only once in subsequent processing. This is an important step to avoid data redundancy and potential conflicts. For each signal after merging and deduplication, its metadata is collected through a series of predefined functions (such as get_data_type, get_size, get_range, get_units, etc.).

[0123] The pseudo code snippet above first integrates the signal definitions from different levels (BSW and SWC), ensures data consistency by deduplication, and then collects metadata information for each signal in detail, providing a solid foundation for subsequent signal processing, simulation, diagnosis, and interaction with hardware, thus completing key tasks such as signal identification and metadata collection for each signal. These tasks are particularly important in automotive electronic software development, especially in processing signal definitions in ECUs, especially in projects based on the AUTOSAR standard, ARXML files are often used to describe ECU configuration information, including signals, data types, sizes, ranges, and units.

[0124] It can be understood that the above metadata (Metadata) contains the attribute fields of each signal, so a storage structure can be designed to store the metadata (Metadata). The pseudo code of the storage structure is as follows:

[0125]

[0126] The main purpose of the pseudo code above is to group a series of signals (all_vfb_signals) according to preset logic (for example, according to functional domains) and create a corresponding storage structure (value_store) for each group to better manage and access these signals, thereby realizing the logical grouping of the original signal list and creating a storage structure with a descriptive name for each group. This storage structure organization method is conducive to improving the modularity, maintainability and scalability of the system. Furthermore, since logically related signals are grouped together, when two signals are logically related, the update frequency is generally similar and can be updated synchronously, thereby indirectly reducing the number of passive updates of some signals and effectively improving communication efficiency.

[0127] Optionally, each of the above storage structures (value_store) represents a set of signals. In the specific practice, code generation can also be performed according to the storage structure (value_store). Here, the pseudo code for code generation is as follows:

[0128]

[0129]

[0130] In the generate_header function of the pseudocode above, first, the preprocessor directives #ifndef and #define are generated to prevent the header file from being included repeatedly, where value_store.name is used to ensure uniqueness. Then, in theory, structure definitions, global variable declarations, function prototypes, etc. are added here. These contents are defined based on the signal information stored in value_store to ensure the consistency of the code and design. Finally, #endif is added to end the preprocessor conditional directive and the generated header file content string.

[0131] In the generate_c_file function of the pseudocode above, the corresponding header file is included at the beginning, using the #include directive, and the file name is composed of value_store.name+".h". Then, in theory, the functions declared in the header file before will be implemented (such as the implementation of signal read and write operations, etc.). This part of the content depends on the information such as value_store.signals, and the generated C source file content string. The above process of looping to generate files includes: for each value_store in the value_stores list, call generate_header and generate_c_file functions to generate the corresponding header file and source file content respectively. Use the write_to_file function (assuming this function exists) to write the generated content into the .h and .c files respectively, and the file name is constructed based on value_store.name.

[0132] The pseudo code above shows how to automatically generate the corresponding C language header and source files based on the previously defined value_store (storage structure) information. This process can be understood as an example of automated code generation, which is common in configuration-driven development environments, such as the AUTOSAR platform, and is used to quickly and consistently generate code that complies with the specification. In the implementation of the above solution, the process of generating C language project files based on the configuration (i.e., value_store object) is realized through automated scripts, which not only improves development efficiency, but also reduces errors caused by manual writing. The generated header and source files follow the standard format of the C language, including necessary preprocessor instructions, structure definitions, function prototypes and implementations, thereby supporting modular programming and code reuse.

[0133] Optionally, the above-mentioned code generation can also be generated in other ways, for example: template-based code generation technology can be used to generate code, and a template engine (such as Jinja2) can be combined with a data model to achieve decoupling of code structure and dynamic data. This method is more flexible than hard coding, and due to the introduction of templates, the maintainability and scalability of the code generation process are significantly improved, ensuring that the generated code not only follows the predetermined structure but is also rich in dynamic content, ultimately achieving improved development efficiency and code quality.

[0134] Optionally, the above code generation can also be generated in other ways, for example: generating code based on a hybrid script approach, where a code generation strategy based on a hybrid script embeds a lightweight scripting language (such as Python), thereby supporting complex logical judgments and data operations during the generation process. The hybrid script-based approach not only greatly enhances the flexibility and scalability of code generation, but also provides a high degree of customization, ultimately achieving rapid adaptation of solutions and efficient customization of code production, and improving the level of intelligent development.

[0135] Optionally, the above-mentioned code generation can also be generated in other ways, for example: generating code based on the configuration method of an interpretable language, setting signals and communication modes by adopting a highly readable configuration language, using structured file descriptions such as XML or JSON, and dynamically generating code with a streamlined runtime interpreter. This strategy effectively avoids the need for frequent compilation, while giving unprecedented flexibility and convenience to the post-deployment configuration adjustment capabilities, greatly enhancing the maintainability and responsiveness of the system.

[0136] As an optional implementation of the above step S120, the above Hypervisor may also manage a shared memory or a message queue; the above implementation of copying the access data to the memory area accessible to the SWC may include:

[0137] Step S125: The access data is copied to a shared memory or a message queue managed by the Hypervisor through the Hypervisor, and the access data in the shared memory or the message queue is used to be read by the SWC.

[0138] It is understandable that since the Hypervisor can find the access data corresponding to the communication request and forward the access data to the corresponding SWC through shared memory or message queues, it can prevent the spread of faults or attacks in a virtual machine to other virtual machines through a strict isolation mechanism. At the same time, the Hypervisor also expands the functions of the traditional RTE layer and effectively replaces part of the role of the traditional RTE layer (for example, copying the access data to the memory area accessible to the SWC through Hypercall). Therefore, the application of Hypervisor in automotive electronic systems enhances the flexibility and security of the system.

[0139] In the implementation of the above solution, the access data is copied to the shared memory or message queue through the Hypervisor and read by the SWC, so that the shared memory and message queue are used as a high-speed inter-process communication mechanism. Compared with other communication methods (such as sockets, pipes, etc.), it can significantly reduce data transmission delay and improve system response speed. The Hypervisor directly intervenes in data replication to ensure the efficiency and timeliness of data transmission, and allows SWC to obtain data through the shared memory or message queue as an intermediate layer without directly interacting with the underlying hardware or runtime environment RTE. This promotes the independence between modules, facilitates system maintenance and upgrades, and enhances system decoupling.

[0140] As an optional implementation of the above step S125, the shared memory or message queue in the above Hypervisor is shared between SWCs in different virtual machines. And / or, the shared memory or message queue in the above Hypervisor is shared between the SWC in the virtual machine and the SWC running on the operating system. And / or, the shared memory or message queue in the above Hypervisor is shared between the SWC in the virtual machine and the basic software BSW, and the BSW runs in the virtual machine or on the operating system.

[0141] In the implementation process of the above scheme, by setting up shared memory or message queues, SWCs in different virtual machines are allowed to share access data to implement a communication mechanism, so that even if the software component (SWC) is moved to another virtual machine, the communication of the SWC is no longer restricted, thereby improving the communication range of the SWC in the virtual machine. In addition, by setting up shared memory or message queues, it is also possible to realize mutual communication between the SWC in the virtual machine and the SWC running on the operating system, and to realize mutual communication between the SWC in the virtual machine and the basic software BSW.

[0142] As an optional implementation of the above method, the method further includes:

[0143] Step S130: The Hypervisor allocates an independent virtual memory space for each virtual machine in the shared memory or the message queue.

[0144] Step S140: The virtual memory spaces corresponding to different virtual machines in the shared memory or message queue are isolated from each other through a protection mechanism to ensure that each virtual machine can only access its allocated virtual memory space. The protection mechanism includes: a hardware memory protection mechanism and / or a software memory protection mechanism.

[0145] It is understandable that the above-mentioned "sharing" refers to memory sharing in physical space, that is, each memory unit may be allocated to any virtual machine, and the above-mentioned "isolation" refers to logical isolation in virtual space, that is, each virtual machine can only access the allocated memory unit (i.e. virtual memory space) and cannot unauthorizedly access the memory units of other virtual machines. Therefore, the above-mentioned "sharing" and "isolation" are not contradictory, and the two are operated at different levels.

[0146] The above-mentioned protection mechanism refers to the protection mechanism of the improved Hypervisor after the Hypervisor is improved, which may include: hardware memory protection mechanism and / or software memory protection mechanism. Among them, the above-mentioned hardware memory protection mechanism, for example: implements the hardware memory protection mechanism by setting a memory protection unit (MPU), so that the accessible memory spaces of different virtual machines are isolated from each other, and the accessible memory space is isolated from the code of the virtual machine management program Hypervisor, effectively increasing the security of the Hypervisor and each virtual machine. The above-mentioned software memory protection mechanism, for example: intercepts and verifies memory access requests from the virtual machine (SWC) through software, thereby preventing unauthorized access operations of the SWC in the virtual machine.

[0147] As an optional implementation of the above method, the above virtual machine (VM) management program Hypervisor can be run as a system component on the operating system, and this Hypervisor can be understood as a managed Hypervisor under the Linux macro operating system. The Hypervisor is used to manage (such as adding, deleting or modifying operations) virtual machines. By running the Hypervisor as a system component on the operating system, the repeated creation of entities such as the operating system and underlying components in the virtual machine is reduced, that is, the repeated creation of the complete operating system and underlying components in each virtual machine is reduced, thereby simplifying the system architecture. At the same time, since the repeated creation of the operating system and the underlying components is reduced, the resource occupation and startup time are reduced, thereby improving the overall performance of the system, and since the Hypervisor runs as a system component of the operating system, it can be uniformly managed and maintained, reducing the maintenance cost and complexity. Since the Hypervisor provides isolation between virtual machines, the security of the system is enhanced. Even if a virtual machine is attacked, other virtual machines and the host system can remain safe, thereby enhancing the overall security of the system.

[0148] See also Figure 4A flow chart of a communication device provided in an embodiment of the present application is shown; an embodiment of the present application provides a communication device 200, which is applied to a controller, a virtual machine and an operating system are running on the controller, and a hypervisor of the virtual machine is running on the operating system. The above-mentioned communication device 200 may include:

[0149] The communication request conversion module 210 is used to convert the access request of the software component SWC to the runtime environment RTE into a communication request of the Hypervisor, and the SWC runs in the virtual machine.

[0150] The data search and forwarding module 220 is used to search for access data corresponding to the communication request and copy the access data to a memory area accessible to the SWC.

[0151] As an optional implementation of the above device, the communication request includes: Hypercall; a communication request conversion module includes:

[0152] The access request conversion submodule is used to convert the access request of the SWC to the RTE into a Hypercall in the RTE wrapper in the virtual machine.

[0153] As an optional implementation of the above device, the data search and forwarding module includes:

[0154] The communication request parsing submodule is used to parse an identifier from the communication request through the Hypervisor. The identifier includes: a variable name, a variable address, or an index ID of a variable address.

[0155] The access data retrieval submodule is used to retrieve the access data corresponding to the Hypercall from the RTE through the Hypervisor according to the variable name, variable address or index ID of the variable address.

[0156] As an optional implementation manner of the above device, the communication device further includes:

[0157] The Hypercall storage module is used to store the Hypercall in the memory area shared by the Hypervisor and the SWC through the virtual machine.

[0158] The Hypercall acquisition module is used to acquire the Hypercall from the memory area through the Hypervisor in a polling mechanism or an interrupt mechanism.

[0159] The first data search module is used to search for access data corresponding to the communication request if the Hypervisor obtains the Hypercall from the memory area.

[0160] As an optional implementation manner of the above device, the communication device further includes:

[0161] The virtual device registration module is used to register the communication service created by the Hypervisor as a virtual device in the operating system.

[0162] The second data search module is used to search for access data corresponding to the communication request if the virtual device is opened and a read operation corresponding to the communication request is detected.

[0163] As an optional implementation manner of the above device, the communication request includes: a trigger request sent by the virtual machine to the Hypervisor through a Trap mechanism; the communication request conversion module includes:

[0164] The instruction execution judgment submodule is used to judge whether the virtual machine where the SWC is located executes the preset instruction through the processor on the controller.

[0165] The communication request conversion submodule is used to suspend the operation of the virtual machine if the virtual machine where the SWC is located executes a preset instruction, and convert the access request of the software component SWC to the runtime environment RTE through the Hypervisor into a trigger request sent by the virtual machine to the Hypervisor through the Trap mechanism.

[0166] As an optional implementation manner of the above device, the communication device further includes:

[0167] The executable file generation module is used to generate the virtual machine and the executable file of the SWC corresponding to the virtual machine. The functions of the executable file include: converting the access request of the SWC to the RTE into the communication request of the Hypervisor.

[0168] As an optional implementation of the above device, the execution file generation module includes:

[0169] The file code acquisition submodule is used to obtain the SWC definition file and SWC code through the SWC editing tool.

[0170] The configuration code and assembly file acquisition submodule is used to obtain the RTE definition file, and configure and compile the RTE definition file and SWC definition file to obtain the RTE assembly file.

[0171] The configuration, compilation and assembly submodule is used to obtain the definition file of the virtual machine, and configure and compile the definition file of the virtual machine to obtain the assembly file of the virtual machine.

[0172] The SWC assembly file acquisition submodule is used to compile and assemble the SWC code to obtain the SWC assembly file;

[0173] The assembly static link submodule is used to statically link the assembly file of the virtual machine and the assembly file of the SWC to obtain an executable file.

[0174] As an optional implementation of the above device, the configuration code and assembly file acquisition submodule includes:

[0175] The scheduling rule parsing unit is used to obtain a static scheduling table, which includes at least one static scheduling rule.

[0176] The definition file compilation unit is used to configure and compile the RTE definition file and the SWC definition file according to the scheduling rules.

[0177] As an optional implementation of the above device, the data search and forwarding module includes:

[0178] The access data copy submodule is used to copy the access data to the shared memory or message queue managed by the Hypervisor through the Hypervisor, and the access data in the shared memory or message queue is used to be read by the SWC.

[0179] As an optional implementation of the above device, the shared memory or message queue is shared between SWCs in different virtual machines. And / or, the shared memory or message queue is shared between the SWC in the virtual machine and the SWC running on the operating system. And / or, the shared memory or message queue is shared between the SWC in the virtual machine and the basic software BSW, and the BSW runs in the virtual machine or on the operating system.

[0180] As an optional implementation manner of the above device, the communication device further includes:

[0181] The memory space allocation module is used by the Hypervisor to allocate independent virtual memory space for each virtual machine in the shared memory or message queue;

[0182] The memory space isolation module is used to isolate the virtual memory spaces corresponding to different virtual machines in the shared memory or message queue through a protection mechanism to ensure that each virtual machine can only access its allocated virtual memory space. The protection mechanism includes: hardware memory protection mechanism and / or software memory protection mechanism.

[0183] As an optional implementation of the above device, the Hypervisor runs as a system component on the operating system, and the Hypervisor is used to manage the virtual machines.

[0184] It should be understood that the device corresponds to the above-mentioned communication method embodiment and can execute the various steps involved in the above-mentioned method embodiment. The specific functions of the device can be referred to in the above description, and the detailed description is appropriately omitted here. The device includes at least one software function module that can be stored in a memory in the form of software or firmware or solidified in the operating system (OS) of the device.

[0185] See also Figure 5 A controller 300 provided in an embodiment of the present application includes: a processor 310 and a memory 320, wherein the memory 320 stores machine-readable instructions executable by the processor 310, and the machine-readable instructions are used by the processor 310 to execute the method described above.

[0186] An embodiment of the present application also provides a vehicle, which includes: a vehicle body and the above-mentioned controller, and the controller is used to control the operation of the vehicle body.

[0187] The embodiment of the present application also provides a computer-readable storage medium 330, on which a computer program is stored, and the computer program is executed by the processor 310 to execute the above method. The computer-readable storage medium 330 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, disk or optical disk.

[0188] The embodiment of the present application also provides a computer program product, including: a computer program or a computer instruction, and the computer program or the computer instruction executes the method described above when executed by a processor.

[0189] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0190] In several embodiments provided in the embodiments of the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are only schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a part of the module, program segment or code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also be different from the order of occurrence marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which is mainly determined by the functions involved. In addition, the functional modules of each embodiment in the embodiments of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. In addition, in the description of this specification, the descriptions with reference to the terms "one embodiment", "some embodiments", "example", "specific example", "some examples", etc. mean that the specific features, structures, materials or characteristics described in combination with the embodiment or example are included in at least one embodiment or example of the embodiments of the present application.

[0191] The above description is only an optional implementation manner of the embodiments of the present application, but the protection scope of the embodiments of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the embodiments of the present application, which should be covered within the protection scope of the embodiments of the present application.

Claims

1. A communication method, characterized in that: Applied to a controller, a virtual machine and an operating system are running on the controller, and a hypervisor of the virtual machine is running on the operating system, the communication method includes: Converting, by means of the virtual machine, an access request of the software component SWC for the runtime environment RTE into a communication request of the Hypervisor, wherein the SWC runs in the virtual machine; The access data corresponding to the communication request is searched through the Hypervisor, and the access data is copied to a memory area accessible to the SWC.

2. The method according to claim 1, characterized in that The communication request includes: Hypercall; the step of converting the access request of the software component SWC to the runtime environment RTE into the communication request of the Hypervisor through the virtual machine includes: In the RTE wrapper in the virtual machine, the access request of the SWC to the RTE is converted into the Hypercall.

3. The method according to claim 2, characterized in that The searching, through the Hypervisor, for access data corresponding to the communication request includes: Parsing an identifier from the communication request through the Hypervisor, where the identifier includes: a variable name, a variable address, or an index ID of the variable address; The Hypervisor retrieves access data corresponding to the Hypercall from the RTE according to the variable name, the variable address or the index ID of the variable address.

4. The method according to claim 2, characterized in that: Before searching the access data corresponding to the communication request through the Hypervisor, the method further includes: Storing the Hypercall in a memory area shared by the Hypervisor and the SWC through the virtual machine; Obtaining the Hypercall from the memory area by the Hypervisor using a polling mechanism or an interrupt mechanism; The searching, through the Hypervisor, for access data corresponding to the communication request includes: If the Hypervisor obtains the Hypercall from the memory area, the access data corresponding to the communication request is searched.

5. The method according to claim 2, characterized in that: Before searching the access data corresponding to the communication request through the Hypervisor, the method further includes: Registering the communication service created by the Hypervisor as a virtual device in the operating system; The searching, through the Hypervisor, for access data corresponding to the communication request includes: If the virtual device is turned on and a read operation corresponding to the communication request is detected, access data corresponding to the communication request is searched.

6. The method according to claim 1, characterized in that The communication request includes: a trigger request sent by the virtual machine to the Hypervisor through a Trap mechanism; the converting of the access request of the software component SWC to the runtime environment RTE into a communication request of the Hypervisor through the virtual machine includes: Determining, by a processor on the controller, whether the virtual machine where the SWC is located executes a preset instruction; If so, the operation of the virtual machine is suspended, and the access request of the software component SWC to the runtime environment RTE is converted by the Hypervisor into a trigger request issued by the virtual machine to the Hypervisor through the Trap mechanism.

7. The method according to claim 1, characterized in that Before converting the access request of the software component SWC to the runtime environment RTE into the communication request of the Hypervisor through the virtual machine, the method further includes: Generate the virtual machine and an executable file of the SWC corresponding to the virtual machine, wherein the function of the executable file includes: converting the access request of the SWC to the RTE into a communication request of the Hypervisor.

8. The method according to claim 7, characterized in that The generating the virtual machine and the executable file of the SWC corresponding to the virtual machine includes: Obtaining a SWC definition file and a SWC code through the SWC editing tool; Obtaining an RTE definition file, and configuring and compiling the RTE definition file and the SWC definition file to obtain an assembly file of the RTE; Obtaining a definition file of the virtual machine, and configuring and compiling the definition file of the virtual machine to obtain an assembly file of the virtual machine; Compile and assemble the SWC code to obtain an assembly file of the SWC; The assembly file of the RTE, the assembly file of the virtual machine and the assembly file of the SWC are statically linked to obtain the executable file.

9. The method according to claim 8, characterized in that The configuring and compiling the RTE definition file and the SWC definition file comprises: Acquire a static scheduling table, wherein the static scheduling table includes: at least one static scheduling rule; The RTE definition file and the SWC definition file are configured and compiled according to the scheduling rules.

10. The method according to claim 1, characterized in that The step of copying the access data to a memory area accessible to the SWC comprises: The access data is copied to a shared memory or the message queue managed by the Hypervisor through the Hypervisor, and the access data in the shared memory or the message queue is used to be read by the SWC.

11. The method according to claim 10, characterized in that The shared memory or the message queue is shared between SWCs in different virtual machines; and / or, the shared memory or the message queue is shared between the SWC in the virtual machine and the SWC running on the operating system; And / or, the shared memory or the message queue is shared between the SWC in the virtual machine and the basic software BSW, and the BSW runs in the virtual machine or on the operating system.

12. The method according to claim 10, characterized in that Also includes: The Hypervisor allocates an independent virtual memory space for each virtual machine in the shared memory or the message queue; The virtual memory spaces corresponding to different virtual machines in the shared memory or the message queue are isolated from each other through a protection mechanism to ensure that each virtual machine can only access its allocated virtual memory space. The protection mechanism includes: a hardware memory protection mechanism and / or a software memory protection mechanism.

13. The method according to any one of claims 1 to 12, characterized in that: The Hypervisor runs as a system component on the operating system, and is used to manage the virtual machine.

14. A communication device, characterized in that: Applied to a controller, a virtual machine and an operating system are running on the controller, a hypervisor of the virtual machine is running on the operating system, and the communication device includes: a communication request conversion module, for converting an access request of a software component SWC for a runtime environment RTE into a communication request of the Hypervisor, the SWC running in the virtual machine; The data search and forwarding module is used to search for access data corresponding to the communication request and copy the access data to a memory area accessible to the SWC.

15. A controller, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the machine-readable instructions are executed by the processor to perform any method according to claims 1 to 13.

16. A vehicle, characterized in that: include: A vehicle body and a controller as claimed in claim 15, wherein the controller is used to control the operation of the vehicle body.

17. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 13 is executed.

18. A computer program product, characterized in that include: A computer program or a computer instruction, wherein when the computer program or the computer instruction is executed by a processor, the method according to any one of claims 1 to 13 is executed.

Citation Information

Cited By

  • Three-layer oriented service architecture realized based on microkernel Hypervisor

    CN121681173A