A USB bus recovery and abnormal device filtering method, device, equipment and medium

By implementing USB bus recovery and abnormal device filtering methods in the Linux kernel, the problem of bus controller shutdown caused by abnormal USB external devices is solved, and automatic recovery of the bus controller and filtering and isolation of abnormal devices are achieved, ensuring system stability and normal operation of devices, and reducing restart and maintenance costs.

CN117707841BActive Publication Date: 2025-09-26XIAMEN FOUR FAITH COMM TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311579809.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-24
Publication Date
2025-09-26
Estimated Expiration
2043-11-24

AI Technical Summary

Technical Problem

In the prior art, when a USB peripheral device malfunctions, the xHCI bus controller driver triggers an exception handling mechanism, causing the bus controller to shut down and all USB peripheral devices to become inoperable. This malfunction cannot be resolved through hot-plugging and can only be restored by restarting the main control device, affecting the stability of the industrial control environment and causing economic losses.

Method used

By implementing the USB bus recovery and abnormal device filtering method in the Linux kernel, including initializing the USB device abnormality list and filter list, automatically recovering the bus controller, filtering and isolating abnormal devices, and recording abnormality logs, it supports hot plugging of normal devices.

Benefits of technology

When a USB external device malfunctions, the bus controller automatically recovers and filters out the abnormal device, ensuring the normal operation of other devices, reducing the restart frequency, improving system stability and fault tolerance, and reducing maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117707841B_ABST
    Figure CN117707841B_ABST
Patent Text Reader

Abstract

The present invention provides a USB bus recovery and abnormal device filtering method, apparatus, device, and medium. In the Linux kernel, when an xHCI bus controller driver is operating and a USB external device is abnormal, triggering a bus abnormality handling mechanism, the bus controller can automatically re-enable itself and, after re-enabling itself, mark the abnormal device or filter and isolate the abnormal device, thereby ensuring that other normal devices under the USB bus controller can continue to operate normally. Hot-swappable support is also provided for abnormal USB external devices, reducing unnecessary device restarts, further improving the fault tolerance and stability of the device system, and reducing on-site system maintenance and maintenance costs. In industrial control applications, USB external devices are very commonly used. Restarting and maintaining control devices often requires shutting down other related devices, which is costly. Therefore, avoiding device restarts and reducing maintenance are very necessary.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of USB bus recovery, and in particular to a USB bus recovery and abnormal device filtering method, device, equipment and medium. Background Art

[0002] Currently, in the xHCI bus controller driver for the Intel-released Linux kernel, when an abnormal USB peripheral device is present on the USB bus, the host device triggers an exception handling mechanism that shuts down the bus controller. In real-world use, it's common for USB device compatibility or device failure to trigger an exception. Once the abnormal bus controller is shut down, the USB hub and all USB peripheral devices connected to the host device's bus become unavailable. Unplugging the abnormal device will not restore normal USB peripheral function. Restoration is only possible by removing the abnormal USB peripheral device and restarting the host device. If the device triggers an exception while unattended, all USB peripheral devices become inoperable, requiring on-site maintenance. Otherwise, normal USB peripheral devices will cease to function properly.

[0003] Simply put, the shortcomings of existing bus controller exception handling mechanisms are quite significant. First, when a USB peripheral device experiences an exception, the handling mechanism directly shuts down the main USB bus controller, resulting in poor fault tolerance. Second, after the USB bus controller is shut down, the bus becomes inoperative, and any connected USB peripherals that function normally also cease to function. Third, after an exception is triggered, hot-plugging the USB peripheral device is not sufficient to resolve the issue; the only solution is to restart the main controller. In some industrial control environments, devices must operate continuously, and restarting the device would inevitably result in financial losses. Fourth, exception handling logs are only output to the terminal; logs cannot be saved for extended periods of operation or restarts, making it impossible to provide effective log tracking for subsequent maintenance and statistical analysis.

[0004] In view of this, this application is filed. Summary of the Invention

[0005] In view of this, the object of the present invention is to provide a USB bus recovery and abnormal device filtering method, apparatus, device and medium, which can effectively solve the problem in the prior art that when an xHCI bus controller driver is working, when a USB external device is abnormal and the bus exception handling mechanism is triggered, the bus controller can automatically re-enable and mark the abnormal device or filter and isolate the abnormal device after enabling.

[0006] The present invention discloses a USB bus recovery and abnormal device filtering method, comprising:

[0007] When a system startup signal is received, the HCD driver module is loaded, the HCD driver module and the main controller are initialized, a USB device exception list and a USB device filter list are established, and the bus recovery work queue and task function of the main controller are initialized. The bus recovery work queue is a whole, which refers to a bus recovery work queue of the USB controller. The work queue needs to be initialized before use, and the bus recovery work queue can be used subsequently;

[0008] When a USB external device is connected to the main control device, the device driver is registered and run for use. At the same time, communication abnormality judgment and list matching judgment are performed to generate a judgment result, and the PID and VID of the abnormal device are written into the filter list or the abnormal list according to the judgment result;

[0009] When a new USB external device is detected, the PID and VID of the external device are obtained, the PID and VID are matched with the filter list to generate a first matching result, and the external device is filtered or not filtered according to the first matching result;

[0010] When a USB device is detected to be removed from the port, the VID and PID of the original device are read, and the VID and PID are matched with the exception list and the filter list to generate a second matching result, and the corresponding ID information is cleared or the device driver is deregistered according to the second matching result;

[0011] The logs when the USB bus controller exception handling mechanism is triggered and the USB abnormal device information are pre-processed, and the processed logs and information are written to the log file in the flash for subsequent troubleshooting and information statistics during maintenance.

[0012] Preferably, when a system startup signal is received, the HCD driver module is loaded, the HCD driver module and the main controller are initialized, a USB device exception list and a USB device filter list are established, and the bus recovery work queue and task function of the main controller are initialized, specifically:

[0013] When a system startup signal is received, the HCD driver module is loaded, the HCD driver module is initialized, and when the HCD driver module is initialized, a USB device exception list and a USB device filter list are established, wherein the HCD driver module is a USB host controller driver module;

[0014] Initialize the main controller, bus recovery work queue and task function;

[0015] When it is determined that the USB external device is abnormal and triggers the bus controller to perform HCD Died processing, the host controller bus recovery work queue is set;

[0016] Call the work queue function to delay execution, and when the work queue function is executed, clear the registered HCD driver, restore HCD and re-register the HCD device.

[0017] Preferably, when a USB external device is connected to the main control device, the device driver is registered and run for use. At the same time, communication abnormality judgment and list matching judgment are performed to generate a judgment result, and the PID and VID of the abnormal device are written into the filter list or the abnormal list according to the judgment result, specifically:

[0018] When a USB external device is connected to the main control device, the device driver is registered and run, and it is determined whether the USB communication fails during the device registration or use process;

[0019] If so, control the USB bus driver to collect the PID and VID of the abnormal device in the message module of the core driver layer and match them with the device abnormality list, wherein the message module is a USB bus communication interface module;

[0020] When it is determined that the PID and VID of the collected abnormal device match the device collected in the device abnormality list, the PID and VID of the abnormal device are written into the filter list;

[0021] When it is determined that the collected PID and VID of the abnormal device do not match the devices collected in the device abnormality list, the PID and VID of the abnormal device are written into the abnormality list.

[0022] Preferably, when a new USB external device is detected, the PID and VID of the external device are obtained, matched with the filter list, a first matching result is generated, and the external device is filtered or not filtered according to the first matching result, specifically:

[0023] The USB bus controller detects USB port changes through the hub driver;

[0024] When a new USB external device is detected, the PID and VID of the external device are obtained and matched with the filter list;

[0025] When it is determined that the PID and VID of the external device match the ID in the filter list, the device is filtered to prevent the device from performing device driver registration, thereby preventing the USB external device from being connected to the system for use;

[0026] When it is determined that the PID and VID of the external device do not match the ID in the filter list, no filtering process is performed and device driver registration is executed.

[0027] Preferably, when it is detected that a USB device is removed from the port, the VID and PID of the original device are read, matched with the exception list and the filter list, a second matching result is generated, and the corresponding ID information is cleared or the device driver is deregistered according to the second matching result, specifically:

[0028] The USB bus controller detects USB port changes through the hub driver;

[0029] When a USB device is detected to be removed from a port, the VID and PID of the original device are read from the port list and matched with the exception list and filter list;

[0030] When it is determined that the read VID and PID of the original device match the exception list and the filter list, the corresponding ID information in the corresponding list is cleared, and the port device information is cleared;

[0031] When it is determined that the read VID and PID of the original device do not match the exception list and the filter list, the device driver is deregistered and the port device information is cleared.

[0032] Preferably, the log when the USB bus controller exception handling mechanism is triggered and the USB abnormal device information are pre-processed, and the processed log and information are written into the log file of the flash, specifically:

[0033] Collect, filter, and remove logs of when the USB bus controller exception handling mechanism is triggered, as well as information about abnormal USB devices;

[0034] The log of triggering the USB bus controller exception handling mechanism after the operation and the USB abnormal device information are written into the log file of the flash for storage.

[0035] The present invention also discloses a USB bus recovery and abnormal device filtering device, comprising:

[0036] An initialization unit, configured to load the HCD driver module upon receiving a system startup signal, initialize the HCD driver module and the main controller, establish a USB device exception list and a USB device filter list, and initialize the bus recovery work queue and task function of the main controller, wherein the bus recovery work queue is a whole and refers to a bus recovery work queue of the USB controller. The work queue needs to be initialized before use before it can be used subsequently;

[0037] An abnormality judgment unit is used to register the device driver and run it when the USB external device is connected to the main control device. At the same time, it performs communication abnormality judgment and list matching judgment, generates a judgment result, and writes the PID and VID of the abnormal device into the filter list or the abnormal list according to the judgment result;

[0038] a first matching unit, configured to, when detecting that a new USB external device is connected, obtain a PID and a VID of the external device, match the PID and the VID with the filter list, generate a first matching result, and filter or not filter the external device according to the first matching result;

[0039] A second matching unit is configured to, when detecting that a USB device is removed from the port, read the VID and PID of the original device, match them with the exception list and the filter list, generate a second matching result, and clear the corresponding ID information or cancel the device driver according to the second matching result;

[0040] The log file writing unit is used to pre-process the log when the USB bus controller exception handling mechanism is triggered and the USB abnormal device information, and write the processed log and information into the flash log file for subsequent maintenance and information statistics.

[0041] The present invention also discloses a USB bus recovery and abnormal device filtering device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, a USB bus recovery and abnormal device filtering method as described in any one of the above 6 is implemented.

[0042] The present invention also discloses a readable storage medium storing a computer program, wherein the computer program can be executed by a processor of a device where the storage medium is located to implement a USB bus recovery and abnormal device filtering method as described in any one of the above.

[0043] In summary, the present embodiment provides a USB bus recovery and abnormal device filtering method, apparatus, device, and medium. In the Linux kernel, when the xHCI bus controller driver is operating and a USB external device abnormality occurs, triggering the bus abnormality handling mechanism, the bus controller can automatically re-enable itself and, after re-enabling, mark the abnormal device or filter and isolate the abnormal device. This ensures that other normal devices under the USB bus controller can continue to operate normally. It also provides hot-plug support for abnormal USB external devices, reducing unnecessary device restarts, further improving the fault tolerance and stability of the device system, and reducing on-site maintenance and maintenance costs. In industrial control application scenarios, USB external devices are very commonly used. Restarting and maintaining control devices often requires shutting down other related devices, which comes at a cost. Therefore, avoiding device restarts and reducing maintenance are very necessary.

[0044] The purposes of the invention are: 1. The USB bus controller exception handling mechanism triggered when a USB external device is abnormal can attempt to restore the bus controller and the USB external device to work; 2. When it is indeed impossible to restore the USB external device to work normally, the abnormal USB external device is filtered and isolated to ensure that other normal USB external devices can continue to work normally in the system; 3. The abnormal device can be removed and replaced with a normal external device by hot plugging, ensuring that the system runs normally and stably without restarting. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 It is a flow chart of a USB bus recovery and abnormal device filtering method provided by the first aspect of the present invention.

[0046] Figure 2 It is a flow chart of a USB bus recovery and abnormal device filtering method provided by the second aspect of the present invention.

[0047] Figure 3 It is a flow chart of a USB bus recovery and abnormal device filtering method provided by the third aspect of the present invention.

[0048] Figure 4 It is a flow chart of a USB bus recovery and abnormal device filtering method provided by the fourth aspect of the present invention.

[0049] Figure 5 The present invention provides a structural diagram of a USB bus recovery and abnormal device filtering device. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions 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. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the invention for which protection is sought, but merely represents selected embodiments of the present invention. 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.

[0051] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0052] See also Figure 1 A first embodiment of the present invention provides a USB bus recovery and abnormal device filtering method, which can be executed by a USB bus recovery and abnormal device filtering device (hereinafter referred to as a filtering device), and in particular, by one or more processors within the filtering device, to implement the following steps:

[0053] See also Figure 2 S101, upon receiving a system startup signal, loads the HCD driver module, initializes the HCD driver module and the main controller, establishes a USB device exception list and a USB device filter list, and initializes the bus recovery work queue and task function of the main controller, wherein the bus recovery work queue is a whole, which refers to a bus recovery work queue of the USB controller. The work queue needs to be initialized before use, and the bus recovery work queue can be used subsequently;

[0054] Specifically, step S101 includes: when receiving a system startup signal, loading an HCD driver module, initializing the HCD driver module, and establishing a USB device exception list and a USB device filter list when the HCD driver module is initialized, wherein the HCD driver module is a USB host controller driver module;

[0055] Initialize the main controller, bus recovery work queue and task function;

[0056] When it is determined that the USB external device is abnormal and triggers the bus controller to perform HCD Died processing, the host controller bus recovery work queue is set;

[0057] Call the work queue function to delay execution, and when the work queue function is executed, clear the registered HCD driver, restore HCD and re-register the HCD device.

[0058] Specifically, in this embodiment, the first step is to load the HCD (USB host controller driver) driver module at system startup. During driver module initialization, the USB device exception list and USB device filter list are established, and the host controller bus recovery work queue and task function are initialized. When a USB external device exception triggers the bus controller to execute HCD Died processing, the host controller bus recovery work queue is set. The system debug work queue function executes with a delayed execution time. During execution, the registered HCD driver is cleared, the HCD is restored, and the HCD device is re-registered with the system.

[0059] See also Figure 3 S102: When a USB external device is connected to the main control device, the device driver is registered and run, and at the same time, communication abnormality judgment and list matching judgment are performed to generate a judgment result, and the PID and VID of the abnormal device are written into the filter list or the abnormal list according to the judgment result;

[0060] Specifically, step S102 includes: when the USB external device is connected to the main control device, registering the device driver and running it for use, and determining whether the USB cannot communicate normally during the device registration or use;

[0061] If so, control the USB bus driver to collect the PID and VID of the abnormal device in the message module of the core driver layer and match them with the device abnormality list, wherein the message module is a USB bus communication interface module;

[0062] When it is determined that the PID and VID of the collected abnormal device match the device collected in the device abnormality list, the PID and VID of the abnormal device are written into the filter list;

[0063] When it is determined that the collected PID and VID of the abnormal device do not match the devices collected in the device abnormality list, the PID and VID of the abnormal device are written into the abnormality list.

[0064] Specifically, in this embodiment, in the second step, when the USB peripheral is connected to the main control device, the device driver is registered and run for use. When the USB cannot communicate normally during device registration or use, the USB bus driver collects the PID and VID of the abnormal device in the message (USB bus communication interface) module of the core driver layer and matches it with the device exception list. When the PID and VID match the devices collected in the device exception list, the PID and VID of the abnormal device are written into the filter list; when they do not match, they are written into the exception list.

[0065] In this embodiment, when collecting the VID and VID of abnormal devices from the message module's exception handling, the abnormal device must first be recorded in the exception list and then enter the filter list after it becomes abnormal again. In this way, when a device is abnormal, the bus can be shut down and then restored to see if the USB external device can resume normal operation. If the abnormal device is not collected again, it can continue to be registered with the system for use. If it is collected again after being collected in the exception list, it indicates that the device abnormality is irreversible. In this case, it needs to be collected in the filter list for filtering and isolation to prevent it from being used again and causing other normal USB external devices to be unable to work in the system.

[0066] See also Figure 4 S103, when a new USB external device is detected, obtaining the PID and VID of the external device, matching them with the filter list, generating a first matching result, and filtering or not filtering the external device according to the first matching result;

[0067] Specifically, step S103 includes: the USB bus controller detects USB port changes through the hub driver;

[0068] When a new USB external device is detected, the PID and VID of the external device are obtained and matched with the filter list;

[0069] When it is determined that the PID and VID of the external device match the ID in the filter list, the device is filtered to prevent the device from performing device driver registration, thereby preventing the USB external device from being connected to the system for use;

[0070] When it is determined that the PID and VID of the external device do not match the ID in the filter list, no filtering process is performed and device driver registration is executed.

[0071] Specifically, in this embodiment, in the third step, the USB bus controller detects changes in the USB port through the hub driver. When a new USB external device is detected, the external device PID and VID are obtained and matched with the filter list. If the PID and VID match the IDs in the filter list, the filtering device does not allow the device to perform device driver registration, thereby preventing the USB external device from being connected to the system for use. If there is no match, no filtering processing is performed and the device driver registration is executed.

[0072] See also Figure 4 S104: When it is detected that a USB device is removed from the port, the VID and PID of the original device are read, matched with the exception list and the filter list, a second matching result is generated, and the corresponding ID information is cleared or the device driver is deregistered according to the second matching result;

[0073] Specifically, step S104 includes: the USB bus controller detects USB port changes through the hub driver;

[0074] When a USB device is detected to be removed from a port, the VID and PID of the original device are read from the port list and matched with the exception list and filter list;

[0075] When it is determined that the read VID and PID of the original device match the exception list and the filter list, the corresponding ID information in the corresponding list is cleared, and the port device information is cleared;

[0076] When it is determined that the read VID and PID of the original device do not match the exception list and the filter list, the device driver is deregistered and the port device information is cleared.

[0077] Specifically, in this embodiment, in the fourth step, the USB bus controller detects changes in the USB port through the hub driver. When it is detected that a USB device is removed from the port, the original device VID and PID are read from the port list and matched with the exception list and the filter list. If there is a match, the corresponding ID information of the corresponding list is cleared and the port device information is cleared. If there is no match, the device driver is deregistered and the port device information is cleared.

[0078] In this embodiment, when an abnormal USB external device is removed from the main control device, the ID information corresponding to the abnormal list and the filter list is cleared to prevent a new normal device from being mistakenly filtered by the system and becoming unusable after being connected.

[0079] S105 , pre-processing the log when the USB bus controller exception handling mechanism is triggered and the USB abnormal device information, and writing the processed log and information into the log file of the flash memory for subsequent troubleshooting and information statistics during maintenance.

[0080] Specifically, step S105 includes: collecting, filtering, and removing logs when the USB bus controller exception handling mechanism is triggered and information about USB abnormal devices;

[0081] The log of triggering the USB bus controller exception handling mechanism after the operation and the USB abnormal device information are written into the log file of the flash for storage.

[0082] Specifically, in this embodiment, in the fifth step, the log of when the USB bus controller exception handling mechanism is triggered, and the USB abnormal device information is collected, filtered, and removed, and the operation log is written into the log file of the flash for subsequent troubleshooting and information statistics during maintenance.

[0083] In summary, the USB bus recovery and abnormal device filtering method has the following advantages:

[0084] (1) When the driver module is initialized, a USB device exception list and a USB device filter list are established, and the main controller bus recovery work queue and task function are initialized to collect abnormal device IDs and recover the USB bus controller.

[0085] (2) The bus controller can resume operation after abnormal shutdown and re-detect the devices connected to the bus controller so that they can be re-registered in the system for use.

[0086] (3) The abnormal USB external device can be detected and registered to the system again through the recovery of the bus controller, and an attempt is made to restore the bus controller to achieve the purpose of restoring the abnormal device.

[0087] (4) If an abnormal USB external device becomes abnormal again after recovery, it will be added to the filter list and filtered and isolated to prevent it from affecting the operation of other USB external devices on the bus.

[0088] (5) After the abnormal device is filtered and isolated, it can be removed from the device system by hot plugging. After being replaced with a new peripheral device, it can continue to be recognized normally by the USB controller and allowed to be registered in the system for use.

[0089] (6) Bus abnormal shutdown recovery and device abnormality, recovery, and filtering are all recorded in the device flash log file to provide log reference.

[0090] See also Figure 5 A second embodiment of the present invention provides a USB bus recovery and abnormal device filtering device, comprising:

[0091] Initialization unit 201 is used to load the HCD driver module upon receiving a system startup signal, initialize the HCD driver module and the main controller, establish a USB device exception list and a USB device filter list, and initialize the bus recovery work queue and task function of the main controller, wherein the bus recovery work queue is a whole, referring to a bus recovery work queue of the USB controller. The work queue needs to be initialized before use, and the bus recovery work queue can be used subsequently;

[0092] The abnormality judgment unit 202 is used to register the device driver and run it when the USB external device is connected to the main control device. At the same time, it performs communication abnormality judgment and list matching judgment, generates a judgment result, and writes the PID and VID of the abnormal device into the filter list or the abnormal list according to the judgment result;

[0093] The first matching unit 203 is configured to, when detecting that a new USB external device is connected, obtain the PID and VID of the external device, match them with the filter list, generate a first matching result, and filter or not filter the external device according to the first matching result;

[0094] The second matching unit 204 is configured to, when detecting that a USB device has been removed from the port, read the VID and PID of the original device, match them with the exception list and the filter list, generate a second matching result, and clear the corresponding ID information or deregister the device driver according to the second matching result;

[0095] The log file writing unit 205 is used to pre-process the log when the USB bus controller exception handling mechanism is triggered and the USB abnormal device information, and write the processed log and information into the log file of the flash for subsequent maintenance and information statistics.

[0096] A third embodiment of the present invention provides a USB bus recovery and abnormal device filtering device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, a USB bus recovery and abnormal device filtering method as described in any one of the above 6 is implemented.

[0097] A fourth embodiment of the present invention provides a readable storage medium storing a computer program, wherein the computer program can be executed by a processor of a device where the storage medium is located to implement a USB bus recovery and abnormal device filtering method as described in any one of the above.

[0098] For example, the computer programs described in the third and fourth embodiments of the present invention may be divided into one or more modules, which are stored in the memory and executed by the processor to implement the present invention. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, each of which is used to describe the execution process of the computer program in the device for implementing a USB bus recovery and abnormal device filtering device. For example, the device described in the second embodiment of the present invention.

[0099] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor serves as the control center of the USB bus recovery and abnormal device filtering method, and utilizes various interfaces and lines to connect the various parts of the method for implementing the USB bus recovery and abnormal device filtering method.

[0100] The memory can be used to store the computer programs and / or modules. The processor implements various functions of a USB bus recovery and abnormal device filtering method by running or executing the computer programs and / or modules stored in the memory and accessing data stored in the memory. The memory may primarily include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function (such as a sound playback function or a text conversion function); the data storage area may store data generated based on the use of the mobile phone (such as audio data, text message data, etc.). Furthermore, the memory may include high-speed random access memory and non-volatile memory, such as a hard disk, internal memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other volatile solid-state storage device.

[0101] If the implemented module is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention can implement all or part of the process steps in the above-mentioned method embodiments by using a computer program to instruct the relevant hardware. The computer program can be stored in a computer-readable storage medium. When executed by a processor, the computer program can implement the steps of each of the above-mentioned method embodiments. The computer program includes computer program code, which can be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium. It should be noted that the content of the computer-readable medium can be appropriately increased or decreased based on the requirements of legislation and patent practice in a jurisdiction. For example, in some jurisdictions, based on legislation and patent practice, computer-readable media does not include electric carrier signals and telecommunication signals.

[0102] It should be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art can understand and implement the present invention without inventive effort.

[0103] The above are only preferred embodiments of the present invention. The protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention.

Claims

1. A USB bus recovery and abnormal device filtering method, characterized in that: include: When the system startup signal is received, the HCD driver module is loaded, the HCD driver module and the main controller are initialized, a USB device exception list and a USB device filter list are established, and the bus recovery work queue and task function of the main controller are initialized. The bus recovery work queue is a whole, which refers to a bus recovery work queue of the USB controller. The work queue needs to be initialized before use, and the bus recovery work queue can be used subsequently. Specifically: Initializing the HCD driver module and establishing a USB device exception list and a USB device filter list when the HCD driver module is initialized, wherein the HCD driver module is a USB host controller driver module; Initialize the main controller, bus recovery work queue and task function; When it is determined that the USB external device is abnormal and triggers the bus controller to perform HCD Died processing, the host controller bus recovery work queue is set; Call the work queue function to delay execution, and when the work queue function is executed, clear the registered HCD driver, restore HCD and re-register the HCD device; When a USB external device is connected to the main control device, the device driver is registered and run for use. At the same time, communication abnormality judgment and list matching judgment are performed to generate a judgment result, and the PID and VID of the abnormal device are written into the filter list or the abnormal list according to the judgment result; When a new USB external device is detected, the PID and VID of the external device are obtained, the PID and VID are matched with the filter list to generate a first matching result, and the external device is filtered or not filtered according to the first matching result; When a USB device is detected to be removed from the port, the VID and PID of the original device are read, and the VID and PID are matched with the exception list and the filter list to generate a second matching result, and the corresponding ID information is cleared or the device driver is deregistered according to the second matching result; The logs when the USB bus controller exception handling mechanism is triggered and the USB abnormal device information are pre-processed, and the processed logs and information are written to the log file in the flash for subsequent troubleshooting and information statistics during maintenance.

2. A USB bus recovery and abnormal device filtering method according to claim 1, characterized in that: When a USB external device is connected to the main control device, the device driver is registered and run. At the same time, communication abnormality judgment and list matching judgment are performed to generate a judgment result. The PID and VID of the abnormal device are written into the filter list or the abnormal list according to the judgment result. Specifically: When a USB external device is connected to the main control device, the device driver is registered and run, and it is determined whether the USB communication fails during the device registration or use process; If so, control the USB bus driver to collect the PID and VID of the abnormal device in the message module of the core driver layer and match them with the device abnormality list, wherein the message module is a USB bus communication interface module; When it is determined that the PID and VID of the collected abnormal device match the device collected in the device abnormality list, the PID and VID of the abnormal device are written into the filter list; When it is determined that the collected PID and VID of the abnormal device do not match the devices collected in the device abnormality list, the PID and VID of the abnormal device are written into the abnormality list.

3. A USB bus recovery and abnormal device filtering method according to claim 2, characterized in that: When a new USB external device is detected, the PID and VID of the external device are obtained, matched with the filter list, and a first matching result is generated. The external device is filtered or not filtered according to the first matching result, specifically: The USB bus controller detects USB port changes through the hub driver; When a new USB external device is detected, the PID and VID of the external device are obtained and matched with the filter list; When it is determined that the PID and VID of the external device match the ID in the filter list, the device is filtered to prevent the device from performing device driver registration, thereby preventing the USB external device from being connected to the system for use; When it is determined that the PID and VID of the external device do not match the ID in the filter list, no filtering process is performed and device driver registration is executed.

4. A USB bus recovery and abnormal device filtering method according to claim 3, characterized in that: When a USB device is detected to be removed from the port, the VID and PID of the original device are read and matched with the exception list and the filter list to generate a second matching result. The corresponding ID information is cleared or the device driver is deregistered according to the second matching result. Specifically: The USB bus controller detects USB port changes through the hub driver; When a USB device is detected to be removed from a port, the VID and PID of the original device are read from the port list and matched with the exception list and filter list; When it is determined that the read VID and PID of the original device match the exception list and the filter list, the corresponding ID information in the corresponding list is cleared, and the port device information is cleared; When it is determined that the read VID and PID of the original device do not match the exception list and the filter list, the device driver is deregistered and the port device information is cleared.

5. A USB bus recovery and abnormal device filtering method according to claim 1, characterized in that: Pre-process the logs and USB abnormal device information when the USB bus controller exception handling mechanism is triggered, and write the processed logs and information to the log file in the flash. Specifically: Collect, filter, and remove logs of when the USB bus controller exception handling mechanism is triggered, as well as information about abnormal USB devices; The log of triggering the USB bus controller exception handling mechanism after the operation and the USB abnormal device information are written into the log file of the flash for storage.

6. A USB bus recovery and abnormal device filtering device, characterized in that: include: The initialization unit is used to load the HCD driver module upon receiving the system startup signal, initialize the HCD driver module and the main controller, establish a USB device exception list and a USB device filter list, and initialize the bus recovery work queue and task function of the main controller. The bus recovery work queue is a whole and refers to a bus recovery work queue of the USB controller. The work queue needs to be initialized before use, and the bus recovery work queue can be used subsequently. Specifically: Initializing the HCD driver module and establishing a USB device exception list and a USB device filter list when the HCD driver module is initialized, wherein the HCD driver module is a USB host controller driver module; Initialize the main controller, bus recovery work queue and task function; When it is determined that the USB external device is abnormal and triggers the bus controller to perform HCD Died processing, the host controller bus recovery work queue is set; Call the work queue function to delay execution, and when the work queue function is executed, clear the registered HCD driver, restore HCD and re-register the HCD device; An abnormality judgment unit is used to register the device driver and run it when the USB external device is connected to the main control device. At the same time, it performs communication abnormality judgment and list matching judgment, generates a judgment result, and writes the PID and VID of the abnormal device into the filter list or the abnormal list according to the judgment result; a first matching unit, configured to, when detecting that a new USB external device is connected, obtain a PID and a VID of the external device, match the PID and the VID with the filter list, generate a first matching result, and filter or not filter the external device according to the first matching result; A second matching unit is configured to, when detecting that a USB device is removed from the port, read the VID and PID of the original device, match them with the exception list and the filter list, generate a second matching result, and clear the corresponding ID information or cancel the device driver according to the second matching result; The log file writing unit is used to pre-process the log when the USB bus controller exception handling mechanism is triggered and the USB abnormal device information, and write the processed log and information into the flash log file for subsequent maintenance and information statistics.

7. A USB bus recovery and abnormal device filtering device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the method for USB bus recovery and abnormal device filtering according to any one of claims 1 to 5 is implemented.

8. A readable storage medium, characterized in that: A computer program is stored, and the computer program can be executed by a processor of the device where the storage medium is located to implement a USB bus recovery and abnormal device filtering method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • 4G module stable working method based on Android system

    CN109766197A

  • Device filtering method and system based on white list

    CN116842500A