Embedded system high fidelity simulation method based on distributed communication
By building an embedded system virtual hardware environment and using DDS middleware for distributed communication, the problem that traditional simulation technology is difficult to simulate the hardware environment and operating system is solved, and high-fidelity simulation and efficient communication are achieved.
Patent Information
- Application Number
- CN202411913784.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-15
AI Technical Summary
Traditional code-based simulation technologies are difficult to simulate the impact of a specific hardware environment and operating system, and distributed systems have low communication efficiency, poor reliability and limited scalability.
By building multiple embedded system virtual hardware environments, configuring a virtual environment network, and using DDS middleware to build distributed communication services, high-fidelity simulation of embedded systems based on distributed communications is realized.
It improves simulation fidelity, improves communication efficiency of distributed systems, and enhances system reliability and scalability.
Smart Images

Figure CN119835330A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of embedded system simulation, and in particular to a high-fidelity simulation method for an embedded system based on distributed communication. Background Art
[0002] With the rapid development of information technology, industrial digitalization and simulation technology have promoted the digital transformation and intelligent upgrading of the manufacturing industry, so as to achieve high-precision digital modeling and simulation of industrial products, production processes and manufacturing systems, thereby reducing the manufacturing and testing of physical prototypes, reducing costs and shortening the product development cycle.
[0003] Traditional code-based simulation technology builds and simulates the behavior of specific systems such as mechanical systems, circuit systems, control systems, etc. by writing code. MBD (Model-Based Design) simulation technology is a method of designing and simulating using digital models. These models can be control flow, state machine or other forms of models. After the design is completed, it can be verified using real-time simulation technology, and it supports direct generation of target code through code generators. MBD-based simulation technology can significantly accelerate the development process and reduce the risk of manual coding errors through automatic code generation. The above methods can achieve model / code-in-the-loop simulation, but these simulation methods may be limited by specific programming languages and environments, and it is difficult to simulate the influence of specific hardware environments and operating systems.
[0004] On the other hand, for distributed systems, each node directly uses data transmission to communicate, which may face risks such as data loss and damage, and may cause high latency due to factors such as network conditions and transmission protocols. In addition, direct data transmission may have security loopholes or deficiencies. Summary of the invention
[0005] Purpose of the invention: To provide a high-fidelity simulation method for an embedded system based on distributed communication, to improve the fidelity of the simulation, to improve the communication efficiency of the distributed system, to enhance the reliability of the system and to improve the scalability of the system.
[0006] Technical solution:
[0007] A high-fidelity simulation method for an embedded system based on distributed communication, comprising:
[0008] Step S1: construct multiple embedded system virtual hardware environments;
[0009] Step S2: Based on the constructed embedded system virtual hardware environment, configure the embedded system virtual environment network to form a distributed embedded system virtual simulation environment;
[0010] Step S3: constructing a distributed communication service based on DDS (Data Distributed Service) middleware according to the distributed embedded system virtual simulation environment;
[0011] Step S4: running the distributed application in a distributed simulation environment for simulation verification, wherein the distributed simulation environment includes: a virtual simulation environment and a distributed communication service.
[0012] Furthermore, in step S1, constructing each embedded system virtual hardware environment includes:
[0013] In the PC host, based on the instruction set of a specific virtual hardware environment, the operating system kernel is cross-compiled to generate an operating system image;
[0014] Create a virtual machine file system;
[0015] Use the Qemu tool to virtualize the specified embedded system hardware environment, including the development board, CPU, and instruction set, load the operating system image into the virtual embedded system hardware environment, and mount the virtual machine file system in the virtual embedded system hardware environment.
[0016] Further, step S2 includes:
[0017] Create virtual network devices in each virtual hardware environment;
[0018] Create the same number of virtual tap network backends in the PC host as the number of virtual hardware environments;
[0019] Set the virtual tap network backend and virtual network device in the PC host to communicate using NAT (Network Address Translation) mode;
[0020] Set up a network address translation policy in the PC host to achieve communication between multiple virtual hardware environments and between the virtual hardware environment and the external network.
[0021] Further, step S3 includes:
[0022] In the PC host, the communication data is described using the interface definition language;
[0023] Create a DDS communication middleware, including domains, topics, data writers, data readers, publishers, and subscribers, where one or more data writers publish defined communication data as topics, and one or more data readers subscribe to messages according to the topic name.
[0024] Further, step S4 includes:
[0025] In the PC host, according to the instruction set of the specific virtual hardware environment, cross-compile the application based on DDS communication to generate an executable file for the target virtual environment;
[0026] Loading executable files of the target environment into the file systems of multiple virtual hardware environments respectively;
[0027] Run the publisher and subscriber programs in each virtual hardware environment, perform task communication through DDS middleware, and realize virtual simulation based on distributed communication.
[0028] Furthermore, in step S2, the operating system image is an open source C code Linux operating system kernel.
[0029] Furthermore, in step S2, the virtual machine file system is a file system created using busybox and contains basic Linux operating instructions.
[0030] Furthermore, in step S3, the DDS is RTI connext DDS.
[0031] Beneficial effects:
[0032] 1. Build a virtual hardware simulation environment to virtualize the development board, CPU, and instruction set, providing a simulation verification platform similar to the actual hardware environment;
[0033] 2. The operating system on which the application runs is virtualized, achieving operating system-in-the-loop simulation, further improving the fidelity of system simulation;
[0034] 3. Constructed multiple virtual hardware environments and interconnected them to form a connection relationship similar to that of real embedded devices, thus building a virtual distributed environment;
[0035] 4. Use DDS middleware for distributed communication, providing a low-latency, high-reliability simulation environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A schematic diagram of a high-fidelity simulation method for an embedded system based on distributed communication is provided for an embodiment of the present invention;
[0037] Figure 2 A schematic diagram of an embedded system topology structure based on distributed communication provided by an embodiment of the present invention; DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0039] The features of various aspects of the embodiments of the present invention will be described in detail below. In the detailed description below, many specific details are proposed to fully understand the present invention. However, it is obvious to those skilled in the art that the present invention can also be implemented without these specific details. The following description of the embodiments is only for a better understanding of the present invention by illustrating examples of the present invention. The present invention is not limited to any specific settings and methods provided below, but covers all product structures, any improvements, replacements, etc. of the methods covered without departing from the spirit of the present invention. In the various drawings and the following description, known structures and technologies are not shown to avoid unnecessary ambiguity of the present invention.
[0040] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other, and the embodiments can refer to and quote each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0041] In order to solve the above problems, the present invention constructs an embedded system virtual simulation environment by means of virtual hardware and loading a specific operating system, and runs an application program for simulation verification, which can improve the fidelity of the simulation to a certain extent.
[0042] Using middleware for communication can significantly improve the communication efficiency of distributed systems, simplify the software development process, enhance system reliability and improve system scalability.
[0043] In the simulation, multiple virtual environments are adapted based on service-oriented middleware, and multiple virtual environments are connected to form a connection relationship similar to that of real embedded devices, so as to verify the distributed embedded system and network.
[0044] Figure 1 The schematic diagram of a high-fidelity simulation method for an embedded system based on distributed communication provided by an embodiment of the present invention includes two parts, namely a distributed simulation environment and a distributed application program.
[0045] Among them, the construction of a distributed simulation environment requires the creation of multiple embedded system virtual simulation environments in the host machine. For each virtual environment, the Qemu tool is used to virtualize the development board, CPU, and instruction set, and the operating system is configured to support the operation of the upper-level application. Specifically, the operating system kernel is compiled using a specific instruction set. At this time, if the instruction set of the host machine is different from the instruction set of the virtual hardware environment, a cross-compilation tool is required to compile the operating system kernel to generate an image file. To build a distributed simulation environment, it is necessary to start multiple virtual machines and configure the virtual machine network separately. The NAT method and the network address translation rules set in the host machine are used to realize the communication between the virtual machine and the host machine, and the communication between virtual machines. On this basis, a distributed communication service based on the DDS middleware is created, including creating a DDS application, creating publishers and subscribers, and creating data writers and readers.
[0046] On the other hand, the creation of distributed applications requires cross-compiling multiple segments of embedded software codes based on DDS communication in the host machine based on the instruction set of a specific virtual hardware environment, generating distributed applications, and loading the application executable files into the file systems of each virtual simulation environment for deployment, and running the applications in the virtual environment to perform simulation verification of the distributed system.
[0047] Figure 2 A schematic diagram of an embedded system structure based on distributed communication provided by an embodiment of the present invention.
[0048] In this embodiment, the host machine is a PC configured with an Ubuntu operating system, and the steps of the simulation method are:
[0049] 1. Build multiple embedded system virtual hardware environments in sequence. In the PC host, based on the instruction set of a specific virtual hardware environment, cross-compile the operating system kernel to generate an operating system image file. Specifically, in this embodiment, the virtual hardware environment using the Qemu tool includes: Vexpress-a9 development board, cortex-a9 CPU, arm processor. In the host PC running the Ubuntu operating system x86-64, use the arm-none-linux-gnueabi cross-compiler to compile the open source Linux operating system source code to generate an arm architecture Linux operating system image;
[0050] Create a virtual machine file system. Specifically, in this embodiment, an sd root file system image is created in the host machine, and a Linux tool set is cross-compiled based on the arm instruction set in the host machine, and the compiled files are copied to the file system image;
[0051] Use the Qemu tool to virtualize the specified embedded system hardware environment, including the development board, CPU, instruction set, etc., and load the operating system kernel image. Specifically, in this embodiment, Qemu is used to virtualize the Vexpress-a9 development board, cortex-a9 CPU, and arm processor in the Ubuntu host (PC host), and the running memory is set to 1024M. When starting the virtual machine (virtual hardware environment), the Linux kernel image is loaded and the sd root file system is mounted.
[0052] 2. Configure the embedded system virtual environment network and build a distributed embedded system virtual simulation environment. Create multiple embedded system virtual hardware environments. Specifically, in this embodiment, the method of step 1 is used to create two virtual hardware environment virtual machines 1 and 2 using the Qemu tool in an Ubuntu host machine, and load the Linux operating system images respectively.
[0053] Create a virtual network device in each virtual machine. Specifically, in this embodiment, create a network device eth0 in virtual machine 1 and virtual machine 2 respectively, set its IP address, and set the IP addresses of the two virtual machines in the same network segment;
[0054] Create the same number of virtual tap network backends in the host machine as the number of virtual environments. Specifically, in this embodiment, create network backends tap0 and tap1 in the Ubuntu host machine, and set the IP address of tap0 to be in the same network segment as the network device eth0 of virtual machine 1, and the IP address of tap1 to be in the same network segment as the network device eth0 of virtual machine 2;
[0055] Set the host virtual tap network backend to communicate with the virtual machine's network device using NAT mode. Specifically, in this embodiment, when starting two Qemu virtual machines, set the host's tap network interface to help the virtual machine establish a network and achieve communication between the virtual machine and the host;
[0056] A network address translation policy is set in the host machine to realize communication between multiple virtual machines and between virtual machines and external networks. Specifically, in this embodiment, a network address translation rule is set in the host machine to perform address translation between messages of the tap0 network segment and the tap1 network segment, so that one virtual machine can receive data from another virtual machine, and the messages of the tap0 and tap1 network segments are respectively set to pass through the local network card outlet to realize communication between the virtual machine and the external network.
[0057] 3. Build a distributed communication architecture based on DDS middleware. In the host machine, use the interface definition language to describe the communication data. Specifically, in this embodiment, there are two sections of C language code automatically generated by the model, one of which sends data to the other end code, and the sent data is described using the interface definition language (IDL);
[0058] Create DDS communication middleware, including domains, topics, data writers, data readers, publishers, and subscribers, where one or more data writers publish defined communication data as topics, and one or more data readers subscribe to messages according to the topic name. Specifically, in this embodiment, the publisher is a program that sends data and is responsible for creating and configuring the data writer. The subscriber is a program that receives data and is responsible for receiving data published under its subscribed topic. Write programs such as creating a DDS application, creating publishers and subscribers, and creating data writers and readers in C code;
[0059] 4. Perform simulation verification in a virtual environment based on distributed communication. In the host machine, according to the instruction set of a specific virtual hardware environment, cross-compile the application based on DDS communication to generate an executable file for the target virtual environment. Specifically, in this embodiment, a cross compiler is used in an Ubuntu host machine to generate an executable file based on the arm instruction set, including DDS publisher and subscriber applications.
[0060] The target environment executable files are loaded into the file systems of multiple virtual machines respectively. Specifically, in this embodiment, the DDS publisher executable file is loaded into the file system of virtual machine 1, and the DDS subscriber executable file is loaded into the file system of virtual machine 2;
[0061] Run the publisher and subscriber programs in the virtual machine, perform task communication through the DDS middleware, and implement virtual simulation based on distributed communication. Specifically, in this embodiment, virtual machine 1 and virtual machine 2 are started respectively, and the publisher and subscriber programs are run, and the program running results are observed to implement task communication through the DDS middleware.
[0062] This embodiment ultimately achieves the use of virtual machines to simulate embedded systems and uses distributed middleware for communication, further improving the fidelity of simulation on the basis of traditional model / code-in-the-loop simulation, while also improving the security and reliability of communication.
[0063] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the field can easily think of various equivalent modifications or substitutions within the technical scope disclosed by the present invention, and these modifications or substitutions should all be covered within the protection scope of the present invention.
Claims
1. A high-fidelity simulation method for embedded systems based on distributed communication, characterized in that: include: Step S1: construct multiple embedded system virtual hardware environments; Step S2: Based on the constructed embedded system virtual hardware environment, configure the embedded system virtual environment network to form a distributed embedded system virtual simulation environment; Step S3: constructing a distributed communication service based on DDS (Data Distributed Service) middleware according to the distributed embedded system virtual simulation environment; Step S4: running the distributed application in a distributed simulation environment for simulation verification, wherein the distributed simulation environment includes: a virtual simulation environment and a distributed communication service.
2. The method according to claim 1, characterized in that In step S1, each embedded system virtual hardware environment is constructed, including: In the PC host, based on the instruction set of a specific virtual hardware environment, the operating system kernel is cross-compiled to generate an operating system image; Create a virtual machine file system; Use the Qemu tool to virtualize the specified embedded system hardware environment, including the development board, CPU, and instruction set, load the operating system image into the virtual embedded system hardware environment, and mount the virtual machine file system in the virtual embedded system hardware environment.
3. The method according to claim 1, characterized in that Step S2 comprises: Create virtual network devices in each virtual hardware environment; Create the same number of virtual tap network backends in the PC host as the number of virtual hardware environments; Set the virtual tap network backend and virtual network device in the PC host to communicate using NAT (Network Address Translation) mode; Set up a network address translation policy in the PC host to achieve communication between multiple virtual hardware environments and between the virtual hardware environment and the external network.
4. The method according to claim 1, characterized in that Step S3 includes: In the PC host, the communication data is described using the interface definition language; Create a DDS communication middleware, including domains, topics, data writers, data readers, publishers, and subscribers, where one or more data writers publish defined communication data as topics, and one or more data readers subscribe to messages according to the topic name.
5. The method according to claim 1, characterized in that Step S4 comprises: In the PC host, according to the instruction set of the specific virtual hardware environment, cross-compile the application based on DDS communication to generate an executable file for the target virtual environment; Loading executable files of the target environment into the file systems of multiple virtual hardware environments respectively; Run the publisher and subscriber programs in each virtual hardware environment, perform task communication through DDS middleware, and realize virtual simulation based on distributed communication.
6. The method according to claim 2, characterized in that In step S2, the operating system image is an open source C code Linux operating system kernel.
7. The method according to claim 1, characterized in that In step S2, the virtual machine file system is a file system created using busybox and contains basic Linux operating instructions.
8. The method according to claim 1, characterized in that: In step S3, the DDS is RTI connext DDS.