Method and device for converting pcie bus to usb bus of vehicle-mounted monitoring board
Patent Information
- Application Number
- CN202210613574.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-31
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2042-05-31
AI Technical Summary
[0004]本发明提供一种车载监控板PCIE总线转USB总线的方法及装置,用以解决现有技术中车载监控板使用串口进行程序烧写和数据拷贝,烧写程序时间长,数据传输速度慢的缺陷,对车载监控板进行完善,增加PCIE总线转USB总线的接口,提高数据传输速度和板卡程序烧写速度
[0037] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for converting the PCIE bus to the USB bus of the vehicle monitoring board as described above.
Smart Images

Figure CN115129648B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of rail transit technology, and in particular to a method and apparatus for converting a vehicle-mounted monitoring board from a PCIE bus to a USB bus. Background Technology
[0002] With the development of technology, the rail transit field is moving towards automation, driverless operation, and interconnectivity. The data transmission of train control equipment in rail transit signaling systems is becoming increasingly large, and there are increasingly higher requirements for data transmission speed.
[0003] Currently, the onboard monitoring boards of rail transit trains use serial ports for program writing and data copying. Program writing takes a long time and data transmission is slow, which cannot meet the ever-increasing data transmission speed requirements of rail transit signaling systems. Summary of the Invention
[0004] This invention provides a method and apparatus for converting a vehicle monitoring board from a PCIe bus to a USB bus, in order to solve the shortcomings of existing vehicle monitoring boards that use serial ports for program writing and data copying, resulting in long program writing times and slow data transmission speeds. The invention improves the vehicle monitoring board by adding a PCIe bus to USB bus interface, thereby increasing data transmission speed and board program writing speed.
[0005] This invention provides a method for converting a vehicle-mounted monitoring board from a PCIe bus to a USB bus. The method is applied to devices based on a Linux system and includes:
[0006] Call the PCIe detection function to mount the PCIe device to the PCIe bus and load the driver for the PCIe device;
[0007] The PCIE detection function is called, the USB detection function is enumerated, and the USB device node is attached to the PCIE bus. The USB detection function is attached to the PCIE bus.
[0008] The USB bus registration function is called to register the USB device node that is attached to the PCIe bus on the USB bus, thus connecting the PCIe bus and the USB bus.
[0009] According to a method for converting a PCIe bus to a USB bus on a vehicle monitoring board provided by the present invention, the step of calling a PCIe detection function to mount a PCIe device onto the PCIe bus and loading the driver of the PCIe device includes:
[0010] The PCIe detection function is invoked to initialize the PCIe device information structure;
[0011] Call the PCIe device enable function to activate the PCIe device;
[0012] Call the PCIE resource request function to request I / O resources for the PCIE device;
[0013] Call the PCIe device configuration function to configure the PCIe device to bus direct register access mode;
[0014] Call the PCIE enable MSI interrupt function to allocate an MSI interrupt to the PCIE device;
[0015] Call the interrupt request function to initialize the MSI interrupt.
[0016] According to a method for converting a PCIe bus to a USB bus on a vehicle monitoring board provided by the present invention, after calling the PCIe device configuration function to configure the PCIe device in direct bus register access mode, the method includes:
[0017] Call the direct register buffer allocation function to allocate a direct register buffer for the PCIe device in the bus direct register access mode.
[0018] According to a method for converting a vehicle monitoring board from a PCIe bus to a USB bus provided by the present invention, the step of calling a PCIe resource request function to request I / O resources of the PCIe device includes:
[0019] Call the PCIE resource base address function to obtain the base address of the I / O resource;
[0020] Call the PCIE resource region length function to obtain the I / O region length of the I / O resource;
[0021] Call the PCIE request region function to request the address space of the I / O resource;
[0022] Call the I / O address space mapping function, which maps the physical addresses of the address space to kernel virtual addresses;
[0023] The PCIE resource request function includes the PCIE resource base address function, the PCIE resource region length function, and the PCIE request region function.
[0024] According to a method for converting a vehicle monitoring board from a PCIe bus to a USB bus provided by the present invention, before calling the USB bus registration function, the method further includes:
[0025] Create a USB controller handle;
[0026] Register the USB bus based on the USB controller handle.
[0027] According to a method for converting a vehicle monitoring board from a PCIe bus to a USB bus provided by the present invention, before calling the PCIe detection function, the method further includes:
[0028] The PCIE bus driver loading function is called to register the PCIE driver handle as a PCIE device driver. The PCIE device driver includes a PCIE device list, the PCIE detection function, and the PCIE release function.
[0029] Once the PCIe device is identified as a device in the PCIe device list, the PCIe detection function is invoked.
[0030] The present invention also provides a device for converting a vehicle monitoring board PCIe bus to a USB bus, the device being applied to a Linux-based device, the device comprising:
[0031] The first processing module is used to call the PCIe detection function to mount the PCIe device to the PCIe bus and load the driver of the PCIe device.
[0032] The second processing module is used to call the PCIE detection function, enumerate the USB detection function, and attach the USB device node to the PCIE bus. The USB detection function is attached to the PCIE bus.
[0033] The third processing module is used to call the USB bus registration function to register the USB device node mounted to the PCIe bus on the USB bus and connect the PCIe bus and the USB bus.
[0034] The present invention also provides a vehicle-mounted monitoring board, comprising:
[0035] Such as the above-mentioned vehicle monitoring board PCIE bus to USB bus device and USB external interface.
[0036] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method of converting the PCIE bus to the USB bus of the vehicle monitoring board as described above.
[0037] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for converting the PCIE bus to the USB bus of the vehicle monitoring board as described above.
[0038] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the method for converting the PCIE bus to the USB bus of the vehicle monitoring board as described above.
[0039] The present invention provides a method and apparatus for converting a vehicle monitoring board PCIE bus to a USB bus. By calling the PCIE detection function, the functionality of the vehicle board's PCIE bus is expanded, allowing devices on the USB bus to be connected to the PCIE bus. This enables the conversion from PCIE interface to USB interface, and the converted USB interface is used for data copying, program burning, and deployment. This facilitates operation and effectively improves the speed of program burning, data copying, log downloading, and data transmission, laying a technical foundation for adding other bus channels to PCIE. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0041] Figure 1 This is a flowchart illustrating the method for converting a PCIE bus to a USB bus in an in-vehicle monitoring board provided by the present invention.
[0042] Figure 2 This is a flowchart illustrating the PCIE bus device scanning and mounting process provided by the present invention;
[0043] Figure 3 This is a flowchart illustrating the USB bus enumeration process provided by the present invention;
[0044] Figure 4 This is a flowchart illustrating the PCIE bus driver process provided by the present invention;
[0045] Figure 5 This is a schematic diagram of the Linux system architecture provided by the present invention;
[0046] Figure 6 This is a schematic diagram of the structure of the vehicle monitoring board provided by the present invention;
[0047] Figure 7 This is a schematic diagram of the device for converting a PCIE bus to a USB bus in a vehicle monitoring board provided by the present invention.
[0048] Figure 8 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0050] In the description of the embodiments of the present invention, it should be noted that the terms "first", "second" and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0051] In the description of the embodiments of the present invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "connected" and "linked" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection, an electrical connection, a wired communication connection, or a wireless communication connection; they can refer to a direct connection or an indirect connection through an intermediate medium. Those skilled in the art can understand the specific meaning of the above terms in the embodiments of the present invention based on the specific circumstances.
[0052] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0053] With the development of technology, the rail transit field is moving towards automation, driverless operation, and interconnectivity. The data transmission of train control equipment in rail transit signaling systems is becoming increasingly large, and there are increasingly higher requirements for data transmission speed.
[0054] Currently, the onboard monitoring boards of rail transit trains use serial ports for program writing and data copying. Program writing takes a long time and data transmission is slow, which cannot meet the ever-increasing data transmission speed requirements of rail transit signaling systems.
[0055] PCIe (PCI Express) is a new generation of high-speed data transmission bus interface. Due to its high transmission rate, for example, PCIe 3.0 can reach a transmission rate of 8Gb / s, it is widely used in data centers, cloud computing, artificial intelligence, machine learning, visual computing, graphics cards, storage and networking.
[0056] PCIe is a high-speed serial computer expansion bus standard. PCIe 4.0 provides a bit rate of 16Gb / s, which is twice the bandwidth provided by PCIe 3.0.
[0057] The buses of train control equipment such as onboard monitoring boards of rail transit trains are gradually moving towards the PCIe bus conversion direction. The original SATA interface has been replaced by the PCIe interface. PCIe 4.0 SSDs are driven by the non-volatile memory NVM Express (NVMe) specification. NVMe SSDs are an excellent choice to replace SATA SSDs, designed specifically for horizontal scaling and ultra-large-scale data transfer environments.
[0058] PCIe maintains backward compatibility with both software support and used mechanical interfaces. The PCIe bus supports hard drives using AHCI, NVMe, and SCSI protocols, and has multiple interfaces such as SATA Express, M.2, PCIe, and U.2. It is very convenient for compatibility with different types of devices. Different types of devices can be plugged into the same slot, such as graphics cards, sound cards, capture cards, adapter cards, hard drives, etc., and can also be connected to the PCIe bus through adapters.
[0059] The following is combined with Figures 1 to 6 This invention describes a method for converting a vehicle monitoring board from a PCIE bus to a USB bus, which improves the vehicle monitoring board by adding a PCIE bus to USB bus interface, thereby increasing data transmission speed and board program burning speed.
[0060] like Figure 1 As shown, the method for converting the PCIE bus to the USB bus on the vehicle monitoring board according to an embodiment of the present invention includes steps 110 to 130.
[0061] In this embodiment of the invention, the method for converting the PCIE bus to a USB bus on the vehicle monitoring board is applied to a Linux-based device, that is, the PCIE bus to USB bus conversion is implemented in the Linux system environment.
[0062] Step 110: Call the PCIE detection function to mount the PCIE device to the PCIE bus and load the PCIE device driver.
[0063] In this step, the PCIe device is mounted on the PCIe bus by calling the PCIe detection function, and the PCIe device driver mounted on the PCIe bus is then executed, thus realizing the mounting and driving of the PCIe device.
[0064] Mounting refers to the process by which the operating system makes computer files and directories on a storage device (such as a hard drive, CD-ROM, or shared resource) accessible to users through the computer's file system. Driving refers to the process that enables the computer to communicate with the corresponding device.
[0065] In this embodiment, the PCIE probe function is a function in the PCIE device driver. The PCIE device driver (pcie_driver()) consists of multiple functions, including the device list (id_table), the PCIE probe function (xhci_pci_probe()), and the release function (remove()).
[0066] The PCIe detection function performs operations such as enabling and initializing the PCIe device. Then, the driver starts file operations, interrupt handling, DMA operations, etc. Finally, it registers the character device with the kernel and enters the boot state.
[0067] Step 120: Call the PCIE detection function, enumerate the USB detection functions, and mount the USB device node to the PCIE bus.
[0068] The USB detection function is connected to the PCIe bus. USB is an abbreviation for Universal Serial Bus, an external bus standard used to regulate the connection and communication between computers and external devices.
[0069] It should be noted that the USB detection function is directly connected to the PCIe bus. By calling the PCIe detection function, the USB device node is attached to the PCIe bus. In related technologies, some PCIe to serial port drivers are registered to the kernel through external KO files. However, in this embodiment of the invention, the PCIe to USB conversion is achieved by directly modifying the kernel function. After the kernel is ported, it directly has the PCIe conversion function.
[0070] In this embodiment, the USB device node is attached to the PCIe bus by calling the PCIe probe function (xhci_pci_probe()) to enumerate the USB probe functions (usb_hcd_pci_probe()) connected to the PCIe bus, and a USB device node is created on the PCIe bus.
[0071] Step 130: Call the USB bus registration function to register the USB device node mounted on the PCIe bus and connect the PCIe bus and the USB bus.
[0072] In this embodiment, a USB device mounted on the USB bus registers the USB device node mounted on the PCIe bus by calling the USB bus registration function (usb_register_bus()), thereby realizing the connection between the PCIe bus and the USB bus.
[0073] Understandably, by calling the USB bus registration function, the USB device mounted on the PCIe bus is registered, and the USB device node mounted on the PCIe bus is connected through the USB bus controller. In this step, the USB bus has added the controller to the USB bus by creating a USB controller handle. Here, the USB bus controller refers to the USB bus master controller in the Linux system.
[0074] In practice, after the PCIE bus and USB bus are connected in the vehicle monitoring board, the USB interface set on the USB bus can be used to upload, download and update various application data, logs and other files more conveniently, and the board application can be burned faster.
[0075] Understandably, the USB interface is one of the standard expansion interfaces and essential interfaces for a large number of computers and smart devices. It has advantages such as ease of use, support for hot-swapping, and flexible connection. In the field of machine vision, most machine vision cameras use the USB standard to connect to the host system. Machine vision is the development direction of intelligent operation and maintenance of signal systems, and it has extremely high requirements for data transmission speed. The PCIE bus adapter provided in this embodiment of the invention can connect devices on the USB bus to the PCIE bus for faster data transmission, which can well meet the development needs of rail transit signal systems.
[0076] The method for converting a vehicle monitoring board from a PCIE bus to a USB bus according to an embodiment of the present invention is based on a Linux system. By calling the same PCIE detection function, the functionality of the vehicle board's PCIE bus is expanded, allowing devices on the USB bus to be mounted on the PCIE bus. This achieves the conversion from a PCIE interface to a USB interface, enabling data copying, program burning, and deployment using the converted USB interface. This facilitates operation and effectively improves the speed of program burning, data copying, log downloading, and data transmission, laying a technical foundation for adding other bus channels to the PCIE.
[0077] In some embodiments, step 110 includes:
[0078] Call the PCIe detection function to initialize the PCIe device information structure;
[0079] Call the PCIe device enable function to activate the PCIe device;
[0080] Call the PCIE resource allocation function to request I / O resources for the PCIE device;
[0081] Call the PCIe device configuration function to configure the PCIe device to direct bus register access mode;
[0082] Call the PCIE enable MSI interrupt function to allocate an MSI interrupt to the PCIE device;
[0083] Call the interrupt request function to initialize the MSI interrupt.
[0084] In this embodiment, the PCIe device information structure stored in the PCIe extended bus device function (XbusPCIe_device()) is initialized in the PCIe probe function (xhci_pci_probe()). The PCIe device information structure is a structure that stores basic device information, and all subsequent structures of various types inherit from the PCIe device information structure.
[0085] The PCIe device is activated by calling the PCIe device enable function (pci_enable_device()). Calling the PCIe device enable function allows the driver to access any resources of the PCIe device, thus enabling the PCIe device to be actually activated.
[0086] In actual execution, the function that has the opposite effect to the PCIe device enable function (pci_enable_device()) is the PCIe device enable interrupt function (pci_disable_device()), which is used to disable the PCIe device.
[0087] Understandably, the Linux system treats devices as special files and integrates them into the file system. Each I / O device, such as a PCIe device, is assigned a path. To mount and drive a PCIe device, the PCIe resource allocation function needs to be called to request the corresponding I / O resources for the PCIe device.
[0088] In this embodiment, the PCIe device configuration function is called to configure the PCIe device in direct register access mode. Direct register access (DMA) allows hardware devices of different speeds to communicate without relying on a large interrupt load from the CPU.
[0089] When implementing DMA transfer, the DMA controller directly manages the bus. Therefore, there is a problem of bus control transfer. Before the DMA transfer, the CPU must hand over bus control to the DMA controller. The DMA transfer copies data from one address space to another. After the DMA transfer ends, the DMA controller should immediately hand over bus control back to the CPU.
[0090] In this embodiment, the operating mode is set to bus master mode. After the PCIe device acquires bus ownership, it processes direct register access operations and calls the PCIe device configuration function (pci_set_master()) to configure the PCIe device to bus direct register access mode.
[0091] Understandably, implementing a PCIe device driver requires MSI (Message Signaled Interrupts) initialization.
[0092] In this embodiment, before calling the request interrupt function (request_irq()), the driver needs to first call the PCIE enable MSI interrupt function (pci_enable_msi()) to allocate an MSI interrupt to the PCIE device, so that the PCIE device switches to MSI mode, and then call the request interrupt function (request_irq()) to register the interrupt for the PCIE device, thus completing the initialization of the MSI interrupt.
[0093] In some embodiments, after calling the PCIe device configuration function to configure the PCIe device to bus direct register access mode, the direct register buffer allocation function can also be called to allocate a direct register buffer for the PCIe device in bus direct register access mode.
[0094] It should be noted that in the PCIe driver, data transmission on the PCIe bus, i.e., data read and write operations, is guaranteed by direct register access operations. The direct register buffer allocation function (pci_alloc_consistent()) is called to allocate a buffer for direct register access operations for data read and write operations.
[0095] In actual execution, the direct register buffer allocation function handles the allocation and mapping of data in the direct register buffer, and its return value is the kernel virtual address of the direct register buffer that guarantees data consistency.
[0096] In some embodiments, requesting I / O resources for a PCIe device is accomplished through the following steps:
[0097] Call the PCIE resource base address function to obtain the base address of the I / O resource;
[0098] Call the PCIE resource region length function to get the I / O region length of the I / O resource;
[0099] Call the PCIe request region function to request address space for I / O resources;
[0100] Call the I / O address space mapping function to map the physical address in the address space to the kernel virtual address;
[0101] The PCIE resource allocation functions include the PCIE resource base address function, the PCIE resource region length function, and the PCIE request region function.
[0102] In this embodiment, the base address and I / O region length of the I / O resource are obtained by calling the PCIE resource base address function (pci_resource_start()) and the PCIE resource region length function (pci_resource_len()).
[0103] It should be noted that the address space requested for I / O resources by calling the PCIe request region function (pci_request_regions()) is a physical address. The kernel needs to use its own virtual address for any memory access, so it is also necessary to call the I / O address space mapping function (ioremap()) to map the physical address to a kernel virtual address so that the address of the I / O resource is available to the kernel.
[0104] In some embodiments, the driver process for a PCIe device also includes a registration process for character devices such as a mouse, keyboard, and console.
[0105] Registering a character device includes allocating a device number, initializing the character device, and adding the device. In this embodiment, the character device number is dynamically registered by calling the dynamic device number allocation function (alloc_chrdev_region()). Then, the major device number (MAJOR()) and minor device number (MINOR()) are obtained respectively. Finally, the character device initialization function (cdev_init()) is called to initialize the structure of the character device and establish a connection between the character device structure and the system call driver function structure (file_operations).
[0106] Finally, the character device is added to the Linux system kernel by calling the character device registration function (cdev_add()) to register a character device structure with the kernel, so that the character device can be put into use.
[0107] In some embodiments, a USB controller handle is created before calling the USB bus registration function; the USB bus is then registered based on the USB controller handle. In this embodiment, a USB controller handle (usb_hcd) is first created, and the host controller is added to the USB bus using the usb_add_hcd() function in the USB controller handle, thus registering the USB bus in the system.
[0108] In some embodiments, before calling the PCIE probe function, the PCIE bus driver loading function is called to register the PCIE driver handle as a PCIE device driver. The PCIE device driver includes a PCIE device list, a PCIE probe function, and a PCIE release function. After determining that the PCIE device is a device in the PCIE device list, the PCIE probe function is called.
[0109] In this embodiment, the PCIE initialization function (xhci_pci_init) registers the PCIE driver handle (xhci_pci_driver) as a PCIE device driver (pcie_driver()) by calling the PCIE bus driver loading function (pcie_register_driver()), thereby initializing the PCIE driver.
[0110] The PCIE device driver (pcie_driver()) includes functions such as the device list (id_table), the PCIE probe function (xhci_pci_probe()), and the release function (remove()).
[0111] The device list (id_table) contains the PCIe device ID (pci_dev_id) and the PCIe vendor ID (pci_vendor_id). During PCIe device initialization, it is necessary to determine whether the PCIe device is a system-supported device in order to determine whether the PCIe device can be driven and function properly.
[0112] Once the PCIe device is confirmed to be in the PCIe device list and it is determined that the PCIe device can be driven normally, the PCIe probe function (xhci_pci_probe()) is called.
[0113] The remove function (remove()) is the function that unloads the PCIE driver. Calling the remove function (remove()) will release the various I / O resources started by the PCIE probe function (xhci_pci_probe()), and then call the PCIE driver unregister function (pcie_driver_unregister()) to unload the PCIE bus driver.
[0114] The following is a detailed description of the scanning and mounting process of PCIe bus devices in the Linux system.
[0115] The PCIe bus has Host / PCIe bridges and PCIe / PCIe bridges. Host / PCIe bridges provide a channel for communication between the CPU and PCIe devices, enabling mapping between the system CPU space and PCIe space. PCIe / PCIe bridges allow for the cascading of PCIe devices.
[0116] like Figure 5 As shown, the PCIe bus in the Linux system has a tree structure. The CPU is connected to the Host / PCIe bridge. PCIe / PCIe bridge 1 and PCIe / PCIe bridge 2 extend from PCIebus1. PCIe device 1 is connected to PCIe bus1, and PCIe device 2 and PCIe device 3 are connected to PCIe bus1 through PCIe / PCIe bridge 2.
[0117] A PCIe / PCIe bridge 3 extends from PCIe bus 2. PCIe bus 3 is connected to PCIe bus 2 through PCIe / PCIe bridge 3. PCIe device 4 is connected to PCIe bus 3.
[0118] In practice, the PCIe bus has a tree structure, and the process of scanning and mounting devices on the PCIe bus is based on a depth-first algorithm.
[0119] like Figure 2 As shown, after the Linux system powers on, it begins scanning for PCIe devices. The PCIe bus scans for PCIe devices connected to this bus. For example, the PCIe devices connected to the PCIe bus include Device1, Device2, and Device3.
[0120] The PCIe bus creates a pci_dev for each PCIe device and attaches it to the devices chain on the bus descriptor, then checks if a PCIe device driver is loaded.
[0121] If a PCIe device driver is loaded, the driver will attach the PCIe device to the bus descriptor's drivers chain.
[0122] At this point, the Linux system's platform mechanism enables automatic matching. When drv->driver.probe equals pci_device_probe, the PCIe device driver takes effect, completing the scanning and mounting of PCIe devices on the PCIe bus.
[0123] The following is a detailed description of the USB bus enumeration process in the Linux system.
[0124] It should be noted that USB is a topology, such as... Figure 5 As shown, USB 3.0 device 1 is connected to PCIe bus 1, USB 3.0 device 2 and USB 3.0 device 3 are connected to PCIe bus 2, and USB 3.0 device 4 is connected to PCIe bus 3.
[0125] The USB bus enumeration is used to identify, address, manage the status of, and dynamically configure connected USB devices.
[0126] like Figure 3 As shown, after a USB device is inserted, an interrupt is triggered by a change in the level of an internal pin, which then enters the bus enumeration.
[0127] The USB protocol defines six states for a device, and the enumeration process alone involves four state transitions: Powered, Default, Address, and Configured.
[0128] Power-on state: A USB device is plugged into the USB port; Default state: Check the USB device status, reset, check if it is a high-speed device, and query the device descriptor; Address state: The host assigns an address to the USB device and enables the new address to communicate with the host; Configuration state: The host mounts the USB device and configures the USB device, successfully activating the USB device and entering the usage state.
[0129] In this embodiment, after four states of the enumeration process, the USB device driver is activated, and the USB device can be used.
[0130] The following is a detailed description of the PCIe bus driver initialization process in the Linux system.
[0131] like Figure 4 As shown, the corresponding modules of the Linux system begin to load, register the PCIE bus driver through pcie_driver, and determine whether it is a supported device based on the device list id_table in the PCIE driver.
[0132] When the device is identified as a supported device, the PCIE detection function is executed to enable the PCIE device, allocate I / O resources for it, and perform interrupt initialization, DMA initialization, and character device initialization. The driver then begins file operations, interrupt handling, DMA operations, and other tasks.
[0133] After the PCIE probe function completes its operation, the release function is called to unload the module and unregister the corresponding PCIE driver. When the PCIE probe function is called again to complete the connection between the PCIE bus and the USB bus, the driver automatically enters the USB bus enumeration process.
[0134] The following describes the device for converting the PCIE bus of an in-vehicle monitoring board to a USB bus provided in the embodiments of the present invention. The device for converting the PCIE bus of an in-vehicle monitoring board to a USB bus described below can be referred to in correspondence with the method for converting the PCIE bus of an in-vehicle monitoring board to a USB bus described above.
[0135] like Figure 7 As shown, the device for converting a vehicle monitoring board PCIE bus to a USB bus provided in this embodiment of the invention includes:
[0136] The first processing module 710 is used to call the PCIE detection function, mount the PCIE device to the PCIE bus, and load the PCIE device driver.
[0137] The second processing module 720 is used to call the PCIE detection function, enumerate the USB detection function, and attach the USB device node to the PCIE bus. The USB detection function is attached to the PCIE bus.
[0138] The third processing module 730 is used to call the USB bus registration function to register USB device nodes mounted on the PCIe bus and connect the PCIe bus and the USB bus.
[0139] The device for converting a vehicle monitoring board from a PCIE bus to a USB bus according to an embodiment of the present invention is provided.
[0140] In some embodiments, the first processing module 710 is configured to call the PCIE probe function to initialize the PCIE device information structure; call the PCIE device enable function to activate the PCIE device; call the PCIE resource request function to request I / O resources for the PCIE device; call the PCIE device configuration function to configure the PCIE device in direct bus register access mode; call the PCIE enable MSI interrupt function to allocate an MSI interrupt for the PCIE device; and call the interrupt request function to initialize the MSI interrupt.
[0141] In some embodiments, the first processing module 710 is used to call the direct register buffer allocation function to allocate a direct register buffer for a PCIe device in bus direct register access mode.
[0142] In some embodiments, the first processing module 710 is used to call the PCIE resource base address function to obtain the base address of the I / O resource; call the PCIE resource region length function to obtain the I / O region length of the I / O resource; call the PCIE request region function to request the address space of the I / O resource; and call the IO address space mapping function to map the physical address of the address space to the kernel virtual address.
[0143] The PCIE resource allocation functions include the PCIE resource base address function, the PCIE resource region length function, and the PCIE request region function.
[0144] In some embodiments, the second processing module 720 is used to create a USB controller handle; and register the USB bus based on the USB controller handle.
[0145] In some embodiments, the first processing module 710 is used to call the PCIE bus driver loading function to register the PCIE driver handle as a PCIE device driver. The PCIE device driver includes a PCIE device list, a PCIE detection function, and a PCIE release function.
[0146] To confirm that the PCIe device is in the PCIe device list, call the PCIe detection function.
[0147] This invention also provides a vehicle-mounted monitoring board.
[0148] The vehicle monitoring board includes, as described above, a device for converting the vehicle monitoring board PCIE bus to a USB bus and a USB external interface.
[0149] The vehicle monitoring board PCIe bus to USB bus device can realize the conversion of PCIe bus to USB bus. When the USB external interface is connected to the vehicle monitoring board PCIe bus to USB bus device, the data writing and data copying speed can be improved through the PCIe bus, reducing time costs.
[0150] like Figure 6 As shown, the vehicle monitoring board can adopt the IMX6 architecture. The vehicle monitoring board is connected to the μPD720202 expansion chip through the PCIE bus and PCIE interface. The device for converting the vehicle monitoring board's PCIE bus to USB bus can be set in the μPD720202 expansion chip.
[0151] In this embodiment, by expanding the μPD720202 chip, two USB 3.0 external interfaces, Port1 and Port2, are added. This allows USB 3.0 devices to be plugged into Port1 and Port2, and data writing and copying can be achieved through the PCIe bus.
[0152] Figure 8 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 8 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830, and a communication bus 840. The processor 810, communication interface 820, and memory 830 communicate with each other via the communication bus 840. The processor 810 can call logical instructions in the memory 830 to execute a method for converting the vehicle monitoring board's PCIe bus to a USB bus. This method is applied to Linux-based devices and includes: calling a PCIe detection function to mount the PCIe device to the PCIe bus and load the PCIe device driver; calling the PCIe detection function to enumerate USB detection functions and mount USB device nodes to the PCIe bus, with the USB detection functions attached to the PCIe bus; and calling a USB bus registration function to register the USB device nodes mounted to the PCIe bus on the USB bus, connecting the PCIe bus and the USB bus.
[0153] Furthermore, the logical instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0154] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the method for converting the vehicle monitoring board PCIE bus to USB bus provided by the above methods. This method is applied to a Linux-based device and includes: calling a PCIE detection function to mount the PCIE device to the PCIE bus and loading the PCIE device driver; calling the PCIE detection function to enumerate USB detection functions and mount the USB device node to the PCIE bus, wherein the USB detection function is attached to the PCIE bus; and calling a USB bus registration function to register the USB device node mounted under the PCIE bus on the USB bus and connect the PCIE bus and the USB bus.
[0155] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the method for converting a vehicle monitoring board PCIe bus to a USB bus provided by the above methods. This method is applied to a Linux-based device and includes: calling a PCIe detection function to mount a PCIe device to the PCIe bus and loading the PCIe device driver; calling the PCIe detection function to enumerate USB detection functions and mount a USB device node to the PCIe bus, wherein the USB detection function is attached to the PCIe bus; and calling a USB bus registration function to register the USB device node mounted under the PCIe bus on the USB bus, thereby connecting the PCIe bus and the USB bus.
[0156] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0157] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0158] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for converting a vehicle-mounted monitoring board from a PCIe bus to a USB bus, the method being applied to a Linux-based device, characterized in that... The method includes: Call the PCIe detection function to mount the PCIe device to the PCIe bus and load the driver for the PCIe device; The PCIE detection function is called, the USB detection function is enumerated, and the USB device node is attached to the PCIE bus. The USB detection function is attached to the PCIE bus. Call the USB bus registration function to register the USB device node mounted to the PCIe bus on the USB bus, and connect the PCIe bus and the USB bus; Before calling the USB bus registration function, the method further includes: Create a USB controller handle; Register the USB bus based on the USB controller handle.
2. The method for converting a vehicle-mounted monitoring board from a PCIE bus to a USB bus according to claim 1, characterized in that, The step of calling the PCIe detection function to mount the PCIe device to the PCIe bus and loading the driver for the PCIe device includes: The PCIe detection function is invoked to initialize the PCIe device information structure; Call the PCIe device enable function to activate the PCIe device; Call the PCIE resource request function to request I / O resources for the PCIE device; Call the PCIe device configuration function to configure the PCIe device to bus direct register access mode; Call the PCIE enable MSI interrupt function to allocate an MSI interrupt to the PCIE device; Call the interrupt request function to initialize the MSI interrupt.
3. The method for converting a vehicle-mounted monitoring board from a PCIE bus to a USB bus according to claim 2, characterized in that, After calling the PCIe device configuration function to configure the PCIe device to bus direct register access mode, the method includes: Call the direct register buffer allocation function to allocate a direct register buffer for the PCIe device in the bus direct register access mode.
4. The method for converting a vehicle-mounted monitoring board from a PCIE bus to a USB bus according to claim 2, characterized in that, The step of calling the PCIe resource request function to request I / O resources for the PCIe device includes: Call the PCIE resource base address function to obtain the base address of the I / O resource; Call the PCIE resource region length function to obtain the I / O region length of the I / O resource; Call the PCIE request region function to request the address space of the I / O resource; Call the I / O address space mapping function, which maps the physical addresses of the address space to kernel virtual addresses; The PCIE resource request function includes the PCIE resource base address function, the PCIE resource region length function, and the PCIE request region function.
5. The method for converting a vehicle-mounted monitoring board from a PCIE bus to a USB bus according to any one of claims 1-4, characterized in that, Before invoking the PCIE probe function, the method further includes: The PCIE bus driver loading function is called to register the PCIE driver handle as a PCIE device driver. The PCIE device driver includes a PCIE device list, the PCIE detection function, and the PCIE release function. Once the PCIe device is identified as a device in the PCIe device list, the PCIe detection function is invoked.
6. A device for converting a vehicle-mounted monitoring board from a PCIe bus to a USB bus, the device being applied to a Linux-based system, characterized in that... The device includes: The first processing module is used to call the PCIe detection function to mount the PCIe device to the PCIe bus and load the driver of the PCIe device. The second processing module is used to call the PCIE detection function, enumerate the USB detection function, and attach the USB device node to the PCIE bus. The USB detection function is attached to the PCIE bus. The third processing module is used to call the USB bus registration function to register the USB device node mounted on the PCIe bus on the USB bus and connect the PCIe bus and the USB bus. Before calling the USB bus registration function, the second processing module is also used to: Create a USB controller handle; Register the USB bus based on the USB controller handle.
7. A vehicle-mounted monitoring board, characterized in that, include: The device for converting the PCIE bus to the USB bus for the vehicle monitoring board and the USB external interface as described in claim 6.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method for converting the PCIE bus to the USB bus of the vehicle monitoring board as described in any one of claims 1 to 5.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the method for converting the PCIE bus to the USB bus of the vehicle monitoring board as described in any one of claims 1 to 5.