Method for identifying USB device, terminal device and system
By combining software and hardware reset, the problem of terminal devices failing to recognize USB devices during startup is solved, achieving efficient USB device recognition without user intervention and improving user experience.
Patent Information
- Application Number
- CN202111015367.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-31
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2041-08-31
AI Technical Summary
Terminal devices may fail to recognize USB devices plugged into the USB port during the boot process, affecting the repair or reinstallation of the operating system. The main reasons include incompatibility of USB interface standards and interference from other USB devices.
By combining software and hardware resets, manual plugging and unplugging operations are simulated to improve the recognition rate of USB devices. Specific steps include: sending a reset command via the USB hub for a software reset; if unsuccessful, sending a reset level signal via the embedded controller for a hardware reset, ensuring that the USB device is powered off before being powered on again.
It can improve the success rate of USB device recognition without the need for manual user intervention, simplify the operation process, and enhance the user experience.
Smart Images

Figure CN115729629B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of electronics, and particularly relates to a USB device identification method, a terminal device and a system. BACKGROUND
[0002] With the rapid development of technology, terminal devices such as notebook computers and desktop computers have become common tools in people's life and work. However, in the process of using the terminal device, the operating system may fail due to various reasons. In order to repair the operating system failure, after the terminal device identifies a universal serial bus (USB) device, the operating system can be repaired or reinstalled by loading a boot program file in the USB device.
[0003] However, in the process of starting the terminal device, there may be a situation that the USB device inserted into the USB port cannot be successfully identified, thereby affecting the repair or reinstallation of the operating system. SUMMARY
[0004] The USB device identification method, the terminal device and the system provided by the present application can improve the success rate of the terminal device identifying the USB device inserted into the USB port, so that the terminal device can use the boot program file in the USB device to repair or reinstall the operating system.
[0005] In a first aspect, the present application provides a USB device identification method applied to a terminal device, and the terminal device has a USB port. The method comprises the following steps: determining whether to start with a USB start item in the process of starting the terminal device; determining whether a USB device is inserted into the USB port when starting with the USB start item; determining whether the USB device is successfully identified as a USB start device when the USB device is inserted into the USB port; performing a software reset operation and determining again whether the USB device is successfully identified as the USB start device when the USB device is not successfully identified as the USB start device; performing a hardware reset operation and continuing to determine whether the USB device is successfully identified as the USB start device when the USB device is not successfully identified as the USB start device; and loading a boot program file in the USB device when the USB device is successfully identified as the USB start device.
[0006] The specific operation performed by the terminal device can be performed by a processor in the terminal device. In this way, when the terminal device fails to successfully identify the USB device as the USB boot device, the USB device can be reset by a software reset mode first, and when the USB device still cannot be identified, the USB device can be reset by a hardware reset mode, so as to power off and then power on the USB device. By the software reset and the hardware reset, the operation of manually plugging and unplugging the USB device is simulated, so as to improve the reliability of identifying the USB device, to possibly restore the identification of the USB device without manual intervention, to simplify the operation of the user, and to improve the user experience.
[0007] In an optional implementation, the terminal device includes a processor and a USB hub connected to each other, and the USB hub is connected to the USB port; the software reset operation includes that the processor controls the USB hub to send a reset instruction to the USB device. In this way, the software reset operation of the USB device is realized by controlling the USB hub to send the reset instruction to the USB device, the execution step of the initialization operation of the USB device after the software reset is reduced, so as to improve the probability that the processor can complete the initialization operation of the USB device within the set time length, and to improve the probability that the processor successfully identifies the USB device as the USB boot device.
[0008] In an optional implementation, after the software reset operation is performed and it is determined again whether the USB device is successfully identified as the USB boot device, the method further includes: when the USB device is not successfully identified as the USB boot device, the software reset operation is continuously performed at least once, and it is determined whether the USB device is successfully identified as the USB boot device after each software reset operation. In this way, the software reset operation is performed multiple times, so as to further improve the probability that the USB device is successfully identified as the USB boot device.
[0009] In an optional implementation, the terminal device includes a processor, an embedded controller and a USB hub connected in sequence; the hardware reset operation includes that the processor controls the embedded controller to send a reset level signal to the USB hub; the reset level signal includes a low-level signal and a high-level signal after an interval of a preset time length. In this way, by performing the hardware reset operation, all the USB devices connected to the USB hub are powered off and then powered on, all the USB devices connected to the terminal device are set to an idle state, so as to reduce the interference of other USB devices connected to the terminal device on the USB device as the USB boot device, and to improve the probability that the USB device as the USB boot device is successfully identified.
[0010] In an alternative implementation, after performing the hardware reset operation and continuing to determine whether the USB device is successfully identified as the USB boot device, the method further comprises: when the USB device is still not successfully identified as the USB boot device, continuing to perform the hardware reset operation at least once, and determining whether the USB device is successfully identified as the USB boot device after each hardware reset operation. In this way, by performing multiple hardware reset operations, the probability of successfully identifying the USB device as the USB boot device is further improved.
[0011] In an alternative implementation, the processor controls the embedded controller to send the reset level signal multiple times, and the preset time length corresponding to the reset level signal sent for the N+1th time is greater than the preset time length corresponding to the reset level signal sent for the Nth time, N being a positive integer. In this way, the preset time length of the reset level signal is set to be greater than the preset time length of the last reset level signal, so that the data in the registers included in the USB device after power-off can be eliminated more thoroughly, the possibility of the USB device being in a fully powered state after the hardware reset is improved, and the possibility of successfully identifying the USB device is further improved.
[0012] In an alternative implementation, the preset time length corresponding to the reset level signal sent for the N+1th time is M times the preset time length corresponding to the reset level signal sent for the Nth time, M being a positive integer greater than 1. In this way, the difficulty of writing the program code corresponding to the preset time length of the multiple reset level signals is reduced.
[0013] In an alternative implementation, the terminal device comprises a processor and a USB hub connected to each other, and the USB hub is connected to the USB port; determining whether the USB device is inserted into the USB port comprises: the processor receiving the connection state reported by the USB hub; and the processor determining whether the USB device is inserted into the USB port according to the connection state.
[0014] In an alternative implementation, determining whether the USB device is successfully identified as the USB boot device comprises: performing an initialization operation on the USB device; and detecting whether the file system type of the USB device and the boot program file type corresponding to the boot program file are read from the USB device. Generally, when the USB device is required to be used for booting, the corresponding boot program file is stored in the USB device, so that whether the USB device is successfully identified as the USB boot device can be detected based on the reading of the file system type and the boot program file type.
[0015] In an alternative implementation, the terminal device comprises a processor and a USB hub connected to each other, and the USB hub is connected to the USB port; the initialization operation on the USB device comprises: the processor performs the initialization operation on the USB port through the USB hub; and the processor performs the configuration operation on the USB device through the USB hub.
[0016] In an alternative implementation, the processor performs the initialization operation on the USB port through the USB hub, comprising: the processor sends a port state acquisition instruction to the USB hub; the processor receives the port state of the USB port returned by the USB hub according to the port state acquisition instruction; when the port state is a busy state, the processor sends a port state clearing instruction to the USB hub to clear the port state of the USB port; and the processor sends a write port state instruction to the USB hub, so that the USB hub sends a reset instruction to the USB device and sets the port state of the USB port to an idle state.
[0017] In an alternative implementation, the processor performs the configuration operation on the USB device through the USB hub, comprising: the processor sends a device descriptor acquisition instruction to the USB device through the USB hub; the processor receives the device descriptor returned by the USB device according to the device descriptor acquisition instruction; when the device type corresponding to the field in the device descriptor is a storage device, the processor sends a configuration descriptor acquisition instruction to the USB device through the USB hub; the processor receives the configuration descriptor returned by the USB device according to the configuration descriptor acquisition instruction; and when the product type corresponding to the field in the configuration descriptor is a U disk, the processor sends a configuration instruction to the USB device through the USB hub to set the USB device to a configuration state.
[0018] In an alternative implementation, the terminal device comprises a processor, an embedded controller, a keyboard and a display screen, the keyboard is connected with the embedded controller, the embedded controller is connected with the processor, the display screen is connected with the processor, the keyboard comprises a first start shortcut key, a start item moving key and a start item saving key; before the processor judges whether to start with the USB start item, it further comprises: in the process of starting up the terminal device, when the processor receives the first start request for the basic input and output system (BIOS) setting interface sent by the embedded controller, the processor controls the display screen to display the BIOS setting interface, the first start request is generated by the embedded controller when detecting the pressing operation on the first start shortcut key, and the BIOS setting interface comprises a start item list, the start item list comprises a hard disk start item, a USB start item and a network start item; when the processor receives the order changing request for the start item list sent by the embedded controller, the processor changes the order of each start item in the start item list, and the order changing request is generated by the embedded controller when detecting the pressing operation on the start item moving key; when the processor receives the saving request for the start item list sent by the embedded controller, the processor saves the start item list, and the saving request is generated by the embedded controller when detecting the pressing operation on the start item saving key; in the process of starting up the terminal device, the processor judges whether to start with the USB start item, comprising: in the process of restarting the terminal device, the processor judges whether the first start item in the saved start item list is the USB start item. In this way, the start order of each start item in the start item list can be changed, the USB start item is set as the first start item in the start item list, and the terminal device is started with the USB start item in the process of restarting the terminal device.
[0019] In an alternative implementation, the terminal device comprises a processor, an embedded controller, a keyboard and a display screen, the keyboard is connected to the embedded controller, the embedded controller is connected to the processor, the display screen is connected to the processor, the keyboard comprises a second start shortcut key and a start item selection key; during the booting process of the terminal device, the processor judges whether to start with the USB start item, comprising: during the booting process of the terminal device, when the processor receives the second start request for the start item selection interface sent by the embedded controller, the processor controls the display screen to display the start item selection interface, the second start request is generated by the embedded controller when detecting the pressing operation on the second start shortcut key, and the start item selection interface at least comprises the USB start item; when the processor receives the start item selection request sent by the embedded controller, the processor determines whether the selected start item is the USB start item according to the start item selection request, and the start item selection request is generated by the embedded controller when detecting the pressing operation on the start item selection key. In this way, without changing the start order of each start item in the start item list, the selected USB start item is directly started during the booting process.
[0020] In a second aspect, the embodiments of the present application provide a terminal device, comprising a processor and a memory; the memory stores computer execution instructions; the processor is configured to execute the computer execution instructions stored in the memory, so that the processor executes the identification method of the USB device.
[0021] In an alternative implementation, the terminal device further comprises a signal adjustment module, the signal adjustment module comprises a first filter unit and a voltage stabilizing unit; the first filter unit is connected to the embedded controller and the USB hub respectively, and is configured to perform filtering processing on the reset level signal output by the embedded controller; one end of the voltage stabilizing unit is connected to the first level signal end, and the other end of the voltage stabilizing unit is connected to the path between the embedded controller and the USB hub, and is configured to perform voltage stabilizing processing on the reset level signal output by the embedded controller. In this way, the anti-interference of the reset level signal output by the embedded controller to the USB hub can be improved through the first filter unit, and the stability of the reset level signal output by the embedded controller to the USB hub can be improved through the voltage stabilizing unit.
[0022] In an alternative implementation, the first filter unit comprises a first resistor and a first capacitor; a first end of the first resistor is connected to the embedded controller, a second end of the first resistor is connected to a first end of the first capacitor, the first end of the first capacitor is also connected to the USB hub, and a second end of the first capacitor is connected to a ground end; the voltage stabilizing unit comprises a voltage stabilizing diode, a positive electrode of the voltage stabilizing diode is connected to the second end of the first resistor, and a negative electrode of the voltage stabilizing diode is connected to the first level signal end.
[0023] In a third aspect, the embodiments of the present application provide a computer readable storage medium, which stores a computer program or instructions, and when the computer program or instructions are executed, the USB device identification method described above is implemented.
[0024] In a fourth aspect, the embodiments of the present application provide a USB device identification system, which comprises a USB device and the terminal device described above, and the USB device stores a boot program file.
[0025] The possible implementation manners of the second aspect to the fourth aspect have similar effects to those in the first aspect and the possible design of the first aspect, and thus are not described here. BRIEF DESCRIPTION OF DRAWINGS
[0026] Figure 1 A flowchart of the USB device identification method in the related art of the embodiments of the present application;
[0027] Figure 2 A schematic diagram of the USB device identification system provided by the embodiments of the present application;
[0028] Figure 3 A flowchart of the USB device identification method provided by the embodiments of the present application;
[0029] Figure 4 A hardware system structure schematic diagram of the terminal device provided by the embodiments of the present application;
[0030] Figure 5 A schematic diagram of a BIOS setting interface provided by the embodiments of the present application;
[0031] Figure 6 A connection schematic diagram of a USB hub and a USB device provided by the embodiments of the present application;
[0032] Figure 7 A relationship schematic diagram of descriptors of a USB device provided by the embodiments of the present application;
[0033] Figure 8 A connection schematic diagram of an embedded controller and a USB hub provided by the embodiments of the present application;
[0034] Figure 9 A flowchart of another USB device identification method provided by the embodiments of the present application;
[0035] Figure 10 A hardware structure schematic diagram of a USB device identification apparatus provided by the embodiments of the present application. DETAILED DESCRIPTION
[0036] In order to clearly describe the technical solutions of the embodiments of the present application, in the embodiments of the present application, the terms "first", "second", etc. are used to distinguish the same or similar items with basically the same function and role. For example, the first chip and the second chip are only used to distinguish different chips, and do not limit the sequence. Those skilled in the art can understand that the terms "first", "second", etc. do not limit the quantity and execution sequence, and the terms "first", "second", etc. also do not necessarily mean different.
[0037] It should be noted that in the embodiments of the present application, the words "exemplary" or "for example" are used to represent an example, illustration or description. Any embodiment or design scheme described as "exemplary" or "for example" in the present application should not be interpreted as more preferred or more advantageous than other embodiments or design schemes. Rather, the words "exemplary" or "for example" are intended to present the relevant concept in a specific manner.
[0038] In the embodiments of the present application, "at least one" means one or more, and "multiple" means two or more. The association relationship of the associated objects is described, which means that there can be three relationships, for example, A and / or B, which can represent the following cases: A exists alone, A and B exist together, and B exists alone, where A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after it. "At least one of the following" or similar expressions means any combination of these items, including any combination of single item or multiple items. For example, at least one of a, b, or c can represent a, b, c, a-b, a-c, b-c, or a-b-c, where a, b, and c can be single or multiple.
[0039] With the continuous development of USB peripheral technology, USB devices have experienced high-speed development from USB1.0, USB1.1, USB2.0 to USB3.0. In order to be compatible with the previous version, the USB bus has developed from the open host controller interface (OHCI) to the universal host controller interface (UHCI), and then to the enhanced host control interface (EHCI), and finally to the current extensible host controller interface (XHCI) technology. The USB bus not only serves as a connection device to provide charging and data transmission tasks, but also expands security specifications to ensure compatibility.
[0040] OHCI is a standard supporting USB1.0, which supports not only USB but also some other interfaces such as IEEE 1394 interface, OHCI is biased to hardware implementation task, and the software driver is relatively simple; UHCI is an interface standard of USB1.0 and USB1.1 led by Intel, which is incompatible with OHCI, the software driver of UHCI is heavy and needs to be relatively complex, but a cheaper and simpler hardware USB controller can be used; EHCI is an interface standard of USB2.0 led by Intel, EHCI only provides high-speed function of USB2.0, and relies on UHCI or OHCI to provide support for full-speed or low-speed devices; xHCI is the latest interface standard of USB3.0, which has greatly improved in speed, energy saving, virtualization and other aspects compared with OHCI, UHCI and EHCI, xHCI supports all kinds of speed USB devices, such as USB3.0 Super-speed, USB2.0 Low-speed, USB2.0 Full-speed, USB2.0 High-speed, USB1.1 Low-speed and USB1.1 Full-speed, etc.
[0041] At present, notebook computers, desktop computers and other terminal devices have become more commonly used tools in people's life and work, and different interface standards of USB interfaces are also provided in these terminal devices.
[0042] In the process of using terminal devices, the operating system of the terminal device often fails due to various reasons, for example, when using the terminal device to surf the Internet, the operating system suddenly crashes due to operation errors or malicious virus software intrusion. Therefore, a corresponding boot program file needs to be set in the USB device (such as a U disk), and the USB device is inserted into the USB port of the terminal device, so that after the terminal device successfully identifies the USB device as a USB startup device, the repair or reinstallation of the operating system is realized based on the boot program file in the USB device.
[0043] Specifically, as Figure 1As shown, in the process of starting up the terminal device, the processor in the terminal device performs step 101 to detect whether the user presses the F12 key on the keyboard. After the F12 key is pressed, the processor controls the display screen of the terminal device to display a startup item selection interface, which includes multiple startup items, such as a USB startup item, a hard disk drive (HDD) startup item, a preboot execute environment (PXE) startup item, and the like. The user can select one of the startup items from the startup item selection interface. After the startup item is selected, the Enter key is pressed, and then the processor performs step 102 to determine whether the startup condition is the USB startup, that is, whether the selected startup item is the USB startup item. When the selected startup item is the USB startup item, the processor performs step 103 to load the BIOS USB boot program. The running process after the BIOS USB boot program is loaded includes subsequently performed steps 104, 105, and 106.
[0044] After step 103, the processor continues to perform step 104 to detect whether a USB device is inserted into the USB port of the terminal device. When it is detected that no USB device is inserted into the USB port of the terminal device, the insertion of the USB device is continued to be waited for. When it is detected that a USB device is inserted into the USB port of the terminal device, the processor performs step 105 to initialize the USB device inserted into the USB port, that is, to complete the configuration and connection of the USB device. After the initialization of the USB device is completed, the processor performs step 106 to detect whether the USB device is successfully identified as the USB startup device. When the USB device inserted into the USB port is successfully identified as the USB startup device, the processor can perform step 107 to load the boot program file in the USB device to repair or reinstall the operating system. When the USB device inserted into the USB port is not successfully identified as the USB startup device, the current execution operation ends, and the boot program file in the USB device cannot be loaded to repair or reinstall the operating system.
[0045] It should be noted that when the user does not press the F12 key on the keyboard, the current execution operation ends. When the selected startup item is not the USB startup item, the processor performs corresponding operations according to the selected startup item. The present embodiment focuses on the scenario in which the startup condition is the USB startup, and does not perform too much description on the scenario in which the startup condition is not the USB startup. That is, when the startup condition is not the USB startup, the flow steps in the present embodiment end.
[0046] In a case that a terminal device cannot successfully identify a USB device as a USB boot device in a start-up process of the terminal device, it is found through analysis that one reason is that the development of USB technology leads to a large number of brands and models of USB devices in the market, and the electrical characteristics of different USB devices are different, that is, the interface standards between the USB interface of the terminal device and the USB device are incompatible. For example, the USB interface of the terminal device is USB3.0, but the USB interface of the inserted USB device is USB2.0 or USB1.0, and the signal transmission rates of the two are different. Since the signal transmission rate of the USB device is lower, the initialization operation of the processor on the USB device cannot be completed in a set time (such as 30 ms), and thus the terminal device may fail to successfully identify the USB device as the USB boot device in the start-up stage.
[0047] Another reason is that there are many USB devices connected to the terminal device, such as a keyboard and a mouse, and these devices connected to the terminal device may interfere with the USB device as the USB boot device, and thus the terminal device may fail to successfully identify the USB device as the USB boot device in the start-up stage.
[0048] If the terminal device cannot successfully identify the USB device inserted into the USB port as the USB boot device, the terminal device cannot load the boot program file in the USB device, and thus the repair or reinstallation of the operating system is affected.
[0049] At present, in order to enable the terminal device to identify the USB device as the USB boot device, all USB devices (such as a keyboard and a mouse) connected to the terminal device can be initialized through multiple restarts of the terminal device, so as to reduce the interference of these devices on the USB device as the USB boot device, or the execution steps in the initialization operation of the USB device after plugging and unplugging can be reduced through multiple plugging and unplugging of the USB device, so as to improve the probability that the processor can complete the initialization operation of the USB device in the set time. Thus, the terminal device can successfully identify the USB device inserted into the USB port as the USB boot device in the start-up stage.
[0050] However, this method requires manual intervention of the user, that is, the user needs to manually restart the terminal device or replug the USB device, and the user operation is cumbersome, which affects the user experience.
[0051] Based on this, the embodiment of the present application provides a USB device identification method. When the processor in the terminal device fails to successfully identify the USB device as a USB startup device, the USB device can be reset through a software reset method, that is, the USB hub is controlled to send a reset instruction to reset the USB device. When the USB device still cannot be successfully identified, the USB device is reset through a hardware reset method, that is, the embedded controller is controlled to send a reset level signal to power off and then power on the USB device. Through the software reset and the hardware reset, the operation of manually plugging and unplugging the USB device is simulated, the identification of the USB device can be restored without manual intervention, the operation of the user is simplified, and the use experience of the user is improved.
[0052] The USB device identification method provided by the embodiment of the present application can be applied to a notebook computer, a tablet computer, a desktop assembled computer, and an all-in-one machine, and a terminal device that needs to be operated by a USB startup device for system repair or reinstallation.
[0053] In order to better understand the embodiment of the present application, the scenario of the USB device identification system of the embodiment of the present application is introduced below. Referring to Figure 2 The USB device identification system includes a terminal device 21 and a USB device 22, Figure 2 The terminal device 21 is taken as a notebook computer for example in the description.
[0054] As shown in a of Figure 2 The USB device 22 has not been inserted into the USB port (not shown) of the terminal device 21, and the boot program file is stored in the USB device 22. If the boot program file in the USB device 22 is needed to be used to reinstall or repair the operating system of the terminal device 22, the USB device 22 can be inserted into the USB port of the terminal device 21 before or during the startup of the terminal device 21, as shown in b of Figure 2
[0055] An exemplary Figure 3 flowchart of the USB device identification method provided by the embodiment of the present application. Referring to Figure 3 The terminal device identification method can include the following steps:
[0056] In step 301, during the startup of the terminal device, the processor detects whether the first startup shortcut key is pressed by the user.
[0057] The USB device identification method in the embodiment of the present application is specifically applied to a terminal device, such as Figure 4 As shown, the terminal device includes a processor 201, a USB hub 202, a USB port, an embedded controller (EC) 204, a keyboard 205, a display screen 206, a sensor 207, a read-only memory (ROM) chip 208, etc.
[0058] In terminal devices, the USB hub 202 can also be referred to as a USB bus. The number of USB ports connected to the USB hub 202 can be one or more, such as... Figure 4 As shown, the terminal device has three USB ports connected to the USB hub 202, namely USB port 203a, USB port 203b, and USB port 203c. Of course, the number of USB ports may vary between different models of terminal devices, and this embodiment does not limit this.
[0059] The processor 201 is connected to the embedded controller 204, the USB hub 202, the display screen 206, the sensor 207 and the ROM chip 208 respectively. The embedded controller 204 is connected to the keyboard 205 and the USB hub 202 respectively. The USB hub 202 is also connected to each USB port.
[0060] In addition, the terminal equipment also includes a power module ( Figure 4 (Not shown in the image) The power module is connected to the processor 201, USB hub 202, embedded controller 204, display screen 206 and ROM chip 208, respectively, and is used to supply power to the connected devices.
[0061] The keyboard 205 is equipped with a power button and a first boot shortcut key. The embedded controller 204 detects the user's press operations on each key on the keyboard 205 in real time. When the user presses the power button, the embedded controller 204 detects the press operation and sends a power-on request to the processor 201. The processor 201 executes the power-on operation according to the power-on request sent by the embedded controller 204, causing the terminal device to start up.
[0062] During the power-on process of the terminal device, the embedded controller 204 detects whether the user has pressed the first startup shortcut key and sends the information on whether the first startup shortcut key has been pressed to the processor 201, thereby enabling the processor 201 to detect the pressing operation of the first startup shortcut key, that is, to detect whether the user has pressed the first startup shortcut key.
[0063] The first startup shortcut key can be the F2 key on the keyboard 205. It should be understood that the first startup shortcut key may be different for different models of terminal devices. In this embodiment, the first startup shortcut key can also be other keys on the keyboard 205, such as the Delete key.
[0064] Step 302: When the processor detects that the user has pressed the first boot shortcut key, the processor controls the display screen to show the BIOS settings interface.
[0065] The following explanation uses F2 as the first boot shortcut key. When the embedded controller 204 detects that the user has pressed the F2 key, the embedded controller 204 generates a first boot request and sends the first boot request to the processor 201. When the processor 201 receives the first boot request sent by the embedded controller 204, the processor 201 can determine that the user has pressed the F2 key. Then, the processor 201 controls the display screen 206 to display the BIOS settings interface according to the first boot request.
[0066] The BIOS is a set of programs embedded in the ROM chip 208 on the motherboard of the terminal device. It provides the lowest-level and most direct hardware settings and control for the computer, and it is the first program that runs when the computer boots up. The BIOS program is responsible for important tasks such as system power-on self-test and hardware initialization. The startup of system applications is guided by the BIOS program.
[0067] like Figure 5 As shown, the BIOS setup interface displays a boot list, which includes hard drive boot (HDD Device), USB boot (USB Device), and network boot (PXE Device).
[0068] Before changing the order of the boot items in the boot list within the BIOS setup interface, the typical boot order of the boot items in the boot list is as follows: Figure 5 As shown in 'a', the first boot option is the hard drive boot option, the second boot option is the USB boot option, and the third boot option is the network boot option.
[0069] In addition, names of various starting devices are displayed in the BIOS setting interface, such as a hard disk name, an extensible firmware interface (EFI) USB device, and the like; detailed information and a starting device state of various starting devices are displayed in the BIOS setting interface, such as a size of a hard disk, a detailed name of a USB device, and a media access control (MAC) address of a PXE device, and the like; and a state of each starting device is in an open state or a closed state. When the state of the starting device is in the open state, it indicates that a starting item corresponding to the starting device is opened; and when the state of the starting device is in the closed state, it indicates that the starting item corresponding to the starting device is closed. The state of each starting device can be controlled from the open state to the closed state, or from the closed state to the open state by using an Enter key on the keyboard 205.
[0070] It should be noted that when the first starting shortcut key (such as the F2 key) on the keyboard is not detected to be pressed by the user, the subsequent steps provided in the present application are not required to be performed, and a normal starting process is directly performed.
[0071] In step 303, when the processor detects that the starting item moving key is pressed by the user, the processor changes the starting order of each starting item in the starting item list.
[0072] The starting item moving key is further provided on the keyboard 205. If the user needs to change the starting order of each starting item in the starting item list in the BIOS setting interface, the starting item moving key can be pressed. When the embedded controller 204 detects that the starting item moving key is pressed by the user, the embedded controller 204 generates a sequence change request and sends the sequence change request to the processor 201. When the processor 201 receives the sequence change request sent by the embedded controller 204, the processor 201 can determine that the starting item moving key is pressed by the user. Then, the processor 201 changes the sequence of each starting item in the starting item list according to the sequence change request.
[0073] The starting item moving key can be the F5 key or the F6 key in the keyboard 205. The F5 key indicates that the starting order of the selected starting item is adjusted forward, and the F6 key indicates that the starting order of the selected starting item is adjusted backward. It should be understood that the starting item moving key corresponding to different models of terminal devices can be different. The starting item moving key in the present application can also be another key on the keyboard 205, and the like.
[0074] The embodiment of the present application needs to adjust the USB startup item to the first startup item in the startup item list. After the cursor selects the USB startup item, the user can press the F5 key to change the USB startup item from the second startup item to the first startup item in the startup item list, so as to change the startup order of each startup item in the startup item list in the BIOS setting interface. The startup order of each startup item in the changed startup item list is shown as b in FIG. 5. Figure 5 It can be seen that in the changed startup item list, the first startup item is the USB startup item, the second startup item is the hard disk startup item, and the third startup item is the network startup item.
[0075] Step 304, when the processor detects that the user presses the startup item save key, the processor saves the changed startup item list.
[0076] The keyboard 205 is also provided with a startup item save key. When the user adjusts the USB startup item to the first startup item in the startup item list, the user can press the startup item save key. When the embedded controller 204 detects that the user presses the startup item save key, the embedded controller 204 generates a save request and sends the save request to the processor 201. When the processor 201 receives the save request sent by the embedded controller 204, the processor 201 can determine that the user presses the startup item save key. Then, the processor 201 saves the changed startup item list according to the save request.
[0077] The startup item save key can be the F10 key in the keyboard 205. It should be understood that the startup item save key corresponding to different models of terminal devices can be different. The startup item save key in the embodiment of the present application can also be other keys on the keyboard 205.
[0078] It should be noted that in some scenarios, if the first startup item in the BIOS setting interface has been set to the USB startup item before the present boot operation, the first startup item in the BIOS setting interface displayed in step 302 is the USB startup item. Therefore, it is not necessary to change the startup order of each startup item in the startup item list, that is, step 303 is not needed to be executed. The user can directly press the startup item save key (such as the F10 key) to exit the BIOS setting interface, or the user can press the combination key of the Ctrl key + Alt key + Delete key to exit the BIOS setting interface. After exiting the BIOS setting interface, the terminal device can continue to execute the processes of steps 305 to 313 in the embodiment of the present application.
[0079] Step 305, during the restart of the terminal device, the processor judges whether the first startup item in the saved startup item list is the USB startup item.
[0080] After the processor 201 saves the changed startup item list, the terminal device is restarted, and during the process of restarting the terminal device, the processor judges whether the first startup item in the saved startup item list is a USB startup item, i.e., judges whether the terminal device is started with the USB startup item.
[0081] After the terminal device is restarted, the BIOS performs a power on self test (POST), which includes sequentially executing the execution code of four phases of the BIOS power on self test stored in the BIOS ROM chip, and after the power on self test, the computer operating system is entered. The four phases are a security phase (SEC), a pre-EFI initialization phase (PEI), a driver execution environment phase (DXE), and a boot device selection phase (BDS).
[0082] The SEC phase mainly accepts the startup, restart, and abnormal signal of the system, opens a space on the Cache as a memory for use, and delivers the system parameters to the PEI phase. The PEI phase mainly performs related preparation work for the DXE phase, i.e., performs initialization operations of the central processing unit (CPU), chip, motherboard, and memory, encapsulates and delivers the parameters required by the DXE phase to the DXE phase. The DXE phase mainly performs a large amount of driver loading and initialization work, i.e., traverses all drivers in the firmware, and when the drivers are all executed, it indicates that the system has completed the initialization operation. The BDS phase mainly loads the necessary device drivers and executes the corresponding startup item according to the user selection, e.g., the user previously sets the first startup item in the startup item list as a USB startup item, and in the BDS phase, it is detected whether the first startup item in the startup item list is a USB startup item.
[0083] Since each phase has its own firmware storage location to be sequentially read and executed in the BIOS power on self test phase, and since these phases have been standardized, the detailed process of the embodiments of the present application will not be described.
[0084] Step 306, when the first startup item in the startup item list is a USB startup item, the processor loads the BIOS USB boot program.
[0085] When the processor determines that the first boot item in the saved boot item list is a USB boot item, the processor loads the BIOS USB boot program. This BIOS USB boot program is mainly used to guide the processor to detect the insertion of a USB device, guide the processor to perform initialization operations on the USB device, and guide the processor to identify the USB device as a USB boot device. That is, the running process after the BIOS USB boot program is loaded includes subsequent steps 307 to 310.
[0086] It should be noted that when the first boot item in the boot item list is not a USB boot item, the processor performs the corresponding operation based on the first boot item in the boot item list, thus ending the process steps in this embodiment.
[0087] Step 307: The processor detects whether a USB device is plugged into the USB port.
[0088] like Figure 6 As shown, a hub controller and D+ and D- signal lines connected to the hub controller are provided in the USB hub 202, and a USB device controller and D+ and D- signal lines connected to the USB device controller are provided in the USB device 22. A second resistor R2 is connected in parallel on the D+ signal line inside the USB device 22. This second resistor R2 can be called a pull-up resistor. One end of the second resistor R2 is connected to the D+ signal line inside the USB device, and the other end of the second resistor R2 is connected to a high-level signal terminal (such as 3.3V). A third resistor R3 is connected in parallel on the D+ signal line inside the USB hub 202, and a fourth resistor R4 is connected in parallel on the D- signal line inside the USB hub 202. The third resistor R3 and the fourth resistor R4 can be called pull-down resistors. One end of the third resistor R3 is connected to the D+ signal line inside the USB hub 202, and the other end of the third resistor R3 is connected to the ground terminal. One end of the fourth resistor R4 is connected to the D- signal line inside the USB hub 202, and the other end of the fourth resistor R4 is connected to the ground terminal.
[0089] When no USB device 22 is plugged into the USB port, the D+ and D- signal lines in the USB hub 202 are pulled low to a low level by the pull-down resistors (i.e., the third resistor R3 and the fourth resistor R4) connected to them, meaning that the levels of the D+ and D- signal lines in the USB hub 202 are both 0. When the USB device 22 is plugged into the USB port, the second resistor R2 and the third resistor R3 are connected in series to divide the voltage, thereby pulling the level of the D+ signal line in the USB hub 202 high. At this time, the level of the D- signal line in the USB hub 202 is still 0.
[0090] It should be understood that, Figure 6The USB device shown is for full-speed or high-speed device, the second resistance R2 is connected with the D+ signal line, and for the USB device for low-speed device, the second resistance R2 is connected with the D- signal line in the USB device 22, when the USB device 22 is inserted into the USB port, the level of the D- signal line in the USB hub 202 is pulled up.
[0091] When the level of a signal line (D+ signal line or D- signal line) in the USB hub 202 is pulled up, the USB hub 202 detects that a USB device is inserted into the USB port, the USB hub 202 reports the connection state of the USB port to the processor 201, and the processor 201 detects whether a USB device is inserted into the USB port according to the connection state reported by the USB hub 202.
[0092] Step 308, when a USB device is inserted into the USB port, the processor performs the initialization operation of the USB port.
[0093] When the connection state reported by the USB hub 202 indicates that a USB device is inserted into the USB port, the processor needs to perform the initialization operation of the USB device, read various descriptor information from the USB device, so that the processor can determine which device is inserted according to the read descriptor information, so that the processor can load the appropriate driver, and prepare for the subsequent communication between the processor and the USB device. The initialization operation of the USB device can also be called the enumeration operation of the USB device. When the connection state reported by the USB hub 202 indicates that no USB device is inserted into the USB port, continue to wait for the insertion of the USB device.
[0094] When the processor performs the initialization operation of the USB device, it mainly includes the initialization operation of the USB port by the processor and the configuration operation of the USB device by the processor.
[0095] The initialization operation of the USB port mainly includes: first, the processor sends a port state acquisition instruction Get_Port_Status to the USB hub, and the USB hub returns the port state of the USB port to the processor in response to the port state acquisition instruction, so that the processor receives the port state of the USB port returned by the USB hub according to the port state acquisition instruction, and the port state is a busy state or an idle state; second, if the port state is the busy state, the processor sends a port state clearing instruction Clear_Port_Feature to the USB hub, and the USB hub clears the flag bit in the port state (Status_Change) register according to the port state clearing instruction, so as to clear the port state of the USB port; third, the processor sends a write port state instruction Set_Port_Feature to the USB hub, and the USB hub sends a reset instruction reset to the USB device in response to the write port state instruction, and the USB hub maintains the reset instruction reset for at least 10 ms, then the USB hub updates the port update (Port_Change) register, and the update of the Port_Change register will update the Status_Change register, so as to set the port state of the USB port to the idle state.
[0096] Optionally, after setting the port state of the USB port to the idle state, the processor can continue to send the port state acquisition instruction Get_Port_Status to the USB hub to determine whether the state of the USB port is the idle state.
[0097] Step 309, the processor performs a configuration operation on the USB device.
[0098] After the initialization operation of the processor on the USB port is completed, the processor needs to perform a configuration operation on the USB device, and the main purpose of the configuration operation is to obtain various descriptor information of the USB device.
[0099] As Figure 7As shown, each USB device has a device descriptor (Device) which determines how many configurations the USB device has, and each configuration has a corresponding configuration descriptor (such as Configuration0 and Configuration1); and in the configuration descriptor, it is defined how many interfaces the configuration has, and each interface has a corresponding interface descriptor (such as Interface0, Interface1, Interface2 and Interface3); and in the interface descriptor, it is defined how many endpoints the interface has, and each endpoint has a corresponding endpoint descriptor (such as Endpoint1, Endpoint2 to Endpoint1X, etc.), which defines the size, type, etc. of the endpoint. As can be seen, the relationship between the descriptors of each USB device is distributed in multiple layers, the topmost layer is the device descriptor, the second layer is the configuration descriptor, the third layer is the interface descriptor, and the bottommost layer is the endpoint descriptor.
[0100] The configuration operation of the USB device is to obtain the corresponding descriptor from the USB device by the processor, to determine the device type and other information of the inserted USB device, so that the processor can load a suitable driver according to the obtained information, to establish a communication mechanism between the processor and the USB device.
[0101] The configuration operation of the USB device mainly includes: in the first step, the processor sends a device descriptor acquisition instruction to the USB device through the USB hub, and the USB device sends its corresponding device descriptor to the processor through the USB hub in response to the device descriptor acquisition instruction. Specifically, the processor can first perform the operation of sending the device descriptor acquisition instruction Get_Device_Desciptor to the USB device to obtain the maximum packet length supported by the default control pipe, and wait for the response of the USB device within a limited time; then, the processor sends a write address instruction Set_Address to the USB device to allocate a unique device address to the USB device, the USB device reads the write address instruction Set_Address, returns an acknowledgement instruction to the processor, and saves the device address allocated by the processor, after which all instructions of the processor to the USB device will be sent to the allocated device address, at this time, the USB device is in the address state; then, the processor sends the device descriptor acquisition instruction Get_Device_Desciptor to the USB device again, and the USB device sends all fields of the device descriptor corresponding to the USB device to the processor in response to the second received device descriptor acquisition instruction. The device descriptor contains information such as the device manufacturer identification VID and product identification PID of the USB device, and the product identification PID can determine the device type of the USB device, i.e., determine which one of the storage device, display device, and charging device the device type of the USB device is.
[0102] In the second step, when the device type corresponding to the field in the device descriptor is a storage device, the processor sends a configuration descriptor acquisition instruction to the USB device through the USB hub, and the USB device sends its corresponding configuration descriptor to the processor through the USB hub in response to the configuration descriptor acquisition instruction. The configuration descriptor includes vendor description, product description (including product type), and model number of the USB device, and the product description refers to whether the USB device with the device type of storage device is a U disk or a mobile hard disk, and the model number refers to the USB interface standard supported by the USB device, for example, whether the USB device is USB2.0 or USB3.0.
[0103] In fact, when the USB device sends its corresponding configuration descriptor to the processor, the USB device also sends the interface descriptor and endpoint descriptor to the processor.
[0104] After receiving the configuration descriptor sent by the USB device, the processor needs to determine whether the corresponding device driver has been installed. When the corresponding device driver has been installed, the device driver is directly loaded, and if the corresponding device driver has not been installed, the installation process of the device driver can be initiated, and the device driver is loaded after the installation is completed.
[0105] Thirdly, when the product type corresponding to the field in the configuration descriptor is a U disk, and the device driver corresponding to the USB device is loaded, the processor generates a configuration value according to the configuration information contained in the configuration descriptor read from the USB device, and then the processor sends a configuration instruction Set_Configuration(x) to the USB device through the USB hub, x represents a non-zero configuration value, if the configuration is successful, the USB device is set to a configuration state.
[0106] After the enumeration of the USB device is completed, the interface and the endpoint in the USB device have a default working configuration, and the USB device completes the necessary configuration and connection work.
[0107] In step 310, the processor detects whether the USB device is successfully identified as a USB boot device.
[0108] In the embodiment of the present application, the USB device stores a boot program file, and the boot program file is an execution program file. After the processor completes the initialization operation on the USB device, the processor attempts to read the type information of the USB device, and the type information includes the file system type of the USB device and the boot program file type corresponding to the boot program file.
[0109] When the processor reads the file system type of the USB device and the boot program file type corresponding to the boot program file from the USB device, it is determined that the USB device is successfully identified as a USB boot device; when the processor does not read the file system type of the USB device and / or the boot program file type corresponding to the boot program file from the USB device, it is determined that the USB device is not successfully identified as a USB boot device.
[0110] Therefore, the processor can detect whether the USB device is successfully identified as a USB boot device based on whether the file system type of the USB device and the boot program file type corresponding to the boot program file are read from the USB device.
[0111] The USB boot device refers to a U disk installed with a WINPE system, which can also be called a winpe U disk. WINPE can be understood as a simplified version of Windows or Windows Server, and PE is directly run without installation and can boot a system microsystem and a minimum operating system.
[0112] For example, the file system type can be a new technology file system (NTFS) type, and the NTFS is a file system of a Windows NT operating environment and a Windows NT advanced server network operating system environment; and the boot file type refers to whether a boot file stored in the USB device is in a Winpeshl.exe format.
[0113] If the processor only detects that the USB device is inserted, but fails to successfully identify the USB device as the USB boot device, the reason for the identification failure is mainly that the initialization operation of the processor on the USB device fails. The initialization operation of the USB device is a series of ordered and consecutive processes, and if any link in the middle requests an error or does not respond within a specified time, the initialization process will fail. After the initialization process fails, the processor will not attempt to read the type information of the USB device, so that the processor cannot read the file system type and the boot file type.
[0114] For example, the interface standard of the USB interface of the U disk is USB2.0, but the interface standard of the USB interface of the terminal device is USB3.0, and the transmission speed of USB3.0 is greater than that of USB2.0. When the processor of the terminal device sends a certain instruction to the USB device in the initialization process, the processor does not receive the response information returned by the USB device based on the instruction within a long time due to the slow transmission speed of the USB interface, so that the entire initialization operation cannot be completed within a specified time. The processor will determine that the initialization process fails, and then the file system type and the boot file type of the USB device cannot be read.
[0115] Step 311, when the USB device is not successfully identified as the USB boot device for the first time, the processor controls the USB hub to send a reset instruction to the USB device for software reset.
[0116] When the processor fails to successfully identify the USB device as the USB boot device for the first time (i.e., i = 1), the processor sends a write port state instruction Set_Port_Feature to the USB hub, and the USB hub sends a reset instruction reset to the USB device in response to the write port state instruction, so that the state of the USB port corresponding to the USB hub returns to the initial state. In this process, the USB hub and the USB device are not powered off. Based on the above method, the software reset of the USB device is realized.
[0117] The processor controls the USB hub to send a reset instruction to the USB device, and after the USB device is software reset, the processor executes steps 309 and 310 again, that is, the configuration operation of the USB device is executed again, and whether the USB device is successfully identified as the USB boot device is detected again (that is, the second time).
[0118] It should be noted that the reason why the USB device as the USB boot device cannot be successfully identified in the startup process of the terminal device can be that the interface standards between the USB interface of the terminal device and the USB device are incompatible, for example, the USB interface of the terminal device is USB3.0, but the USB interface of the inserted USB device is USB2.0 or USB1.0. Since the signal transmission rate of the USB device is low, the initialization operation of the processor on the USB device can not be completed in the set time length, that is, the initialization operation of the processor on the USB device can only be partially executed in the set time length, and all operations cannot be completed. For example, when the processor initializes the USB device, the port state of the USB port is first acquired. When the port state is busy, the processor needs to clear the port state of the USB port, and then sends a reset instruction to the USB device through the USB hub to set the port state of the USB port to idle. If the time length of these steps reaches the set time length, the initialization operation of the processor on the USB device is not completed in the set time length, and the initialization operation of the processor on the USB device fails.
[0119] However, since the previous initialization operation has already executed some operations, these operations will reduce the execution steps of the initialization operation on the USB device after the software reset operation. For example, in the first initialization operation, the port state of the USB port is set to idle, so after the software reset operation is executed, the port state clearing operation when the port state is busy does not need to be executed again.
[0120] Therefore, the execution steps of the initialization operation on the USB device after the software reset operation are reduced in the embodiment of the present application, so as to improve the probability that the processor can complete the initialization operation on the USB device in the set time length, and improve the probability that the processor successfully identifies the USB device as the USB boot device.
[0121] It can be understood that, when the processor fails to identify the USB device as the USB boot device for the first time (i.e. i=1), the processor performs a software reset operation on the USB device, and then detects again whether the USB device is successfully identified as the USB boot device after the software reset operation. When the USB device is not successfully identified as the USB boot device, the processor directly performs the hardware reset operation in step 312. Alternatively, when the processor fails to identify the USB device as the USB boot device after the software reset operation, the processor can continue to perform at least one software reset operation, and detects whether the USB device is successfully identified as the USB boot device after each software reset operation.
[0122] Optionally, the processor performs the software reset operation on the USB device as the USB boot device for K times, where K is a positive integer. When the processor fails to identify the USB device as the USB boot device after the Kth software reset operation, the processor performs the hardware reset operation in step 312.
[0123] In step 312, when the USB device is not successfully identified as the USB boot device for the first time, the processor controls the embedded controller to send at least one reset level signal to the USB hub to reset the USB device in hardware.
[0124] After the processor resets the USB device in software, when the processor fails to identify the USB device as the USB boot device for the second time (i.e. i=2), the processor sends a control instruction to the embedded controller. The embedded controller sends a low-level signal to the USB hub according to the control instruction, and the USB hub controls the USB device to be powered off based on the low-level signal. After waiting for a preset time interval, the embedded controller sends a high-level signal to the USB hub, and the USB hub controls the USB device to be powered on based on the high-level signal. In this way, the USB device is reset in hardware. For the convenience of description, the low-level signal and the high-level signal after the preset time interval are collectively referred to as a reset level signal.
[0125] After the processor controls the embedded controller to send the reset level signal to the USB hub to reset the USB device in hardware, the processor performs steps 308, 309 and 310 again, i.e. continues to perform the initialization operation on the USB device (including the initialization operation on the USB port and the configuration operation on the USB device), and continues to detect (i.e. for the third time) whether the USB device is successfully identified as the USB boot device.
[0126] When the USB device is not successfully identified as the USB boot device for the third time (i.e., i=3), the processor continues to perform step 312, step 308, step 309, and step 310, and when step 310 is performed, the USB device is detected whether to be successfully identified as the USB boot device for the fourth time (i.e., i=4); when the USB device is not successfully identified as the USB boot device for the fourth time, the processor continues to perform step 312, step 308, step 309, and step 310, and when step 310 is performed, the USB device is detected whether to be successfully identified as the USB boot device for the fifth time; when the USB device is not successfully identified as the USB boot device for the fifth time (i.e., i=5), the execution process of the embodiment of the present application ends, indicating that the USB device as the USB boot device is still not successfully identified after the software reset and the three times of hardware reset.
[0127] The above process indicates that the execution times of the hardware reset in the embodiment of the present application can be three times, i.e., the processor controls the embedded controller to send three times of reset level signals to the USB hub. It can be understood that the execution times of the hardware reset in the embodiment of the present application can not be limited to three times, and can be one time, two times, or four times, etc.
[0128] It should be noted that when the USB device as the USB boot device is still not successfully identified after the software reset operation, the reason can be that other USB devices connected to the terminal device interfere with the USB device as the USB boot device, resulting in that the USB device as the USB boot device cannot be successfully identified. Therefore, the embodiment of the present application performs the hardware reset operation, so that all the USB devices connected with the USB hub are powered off and then powered on, and all the USB devices connected to the terminal device are set to an idle state, thereby reducing the interference of other USB devices connected to the terminal device on the USB device as the USB boot device, and improving the probability of successfully identifying the USB device as the USB boot device.
[0129] In some embodiments, the processor controls the embedded controller to send multiple times of reset level signals, i.e., the execution times of the hardware reset are multiple times, the preset time length corresponding to the reset level signal sent for the N+1 time is greater than the preset time length corresponding to the reset level signal sent for the N time, and N is a positive integer.
[0130] For example, the processor controls the embedded controller to send three times of reset level signals to the USB hub, the preset time length corresponding to the reset level signal sent for the second time is greater than the preset time length corresponding to the reset level signal sent for the first time, and the preset time length corresponding to the reset level signal sent for the third time is greater than the preset time length corresponding to the reset level signal sent for the second time.
[0131] The preset time length corresponding to the N+1th reset level signal is greater than the preset time length corresponding to the Nth reset level signal, mainly because after the USB device is powered off by the low level signal included in the reset level signal, the data in the register included in the USB device will gradually disappear, and if the time between the low level signal and the high level signal is short, the data in the register included in the USB device may not be completely eliminated. Therefore, after the USB device is powered on again by the high level signal included in the reset level signal, the USB device is actually not in a complete power-on state. Therefore, the preset time length corresponding to the N+1th reset level signal is greater than the preset time length corresponding to the Nth reset level signal, which can make the data in the register included in the USB device after power-off more completely eliminated, improve the possibility of the USB device in a complete power-on state after hardware reset, and further improve the possibility of successfully identifying the USB device.
[0132] Optionally, the preset time length corresponding to the N+1th reset level signal is M times of the preset time length corresponding to the Nth reset level signal, and M is a positive integer greater than 1.
[0133] For example, M can be 2, the processor controls the embedded controller to send 3 reset level signals to the USB hub, the preset time length corresponding to the 2nd reset level signal is 2 times of the preset time length corresponding to the 1st reset level signal, and the preset time length corresponding to the 3rd reset level signal is 2 times of the preset time length corresponding to the 2nd reset level signal.
[0134] Taking the preset time length corresponding to the 1st reset level signal as 50ms for example, the preset time length corresponding to the 2nd reset level signal is 100ms, and the preset time length corresponding to the 3rd reset level signal is 200ms.
[0135] The preset time length corresponding to the N+1th reset level signal is an integer multiple of the preset time length corresponding to the Nth reset level signal, mainly from the perspective of program code implementation. Under normal circumstances, the preset time lengths corresponding to adjacent two hardware resets are in an integer multiple relationship, and the coding rules during code writing are simpler.
[0136] It can be understood that the ratio of the preset time length corresponding to the N+1th reset level signal to the preset time length corresponding to the Nth reset level signal can be equal to the ratio of the preset time length corresponding to the Nth reset level signal to the preset time length corresponding to the N-1th reset level signal, of course, it can also not be equal.
[0137] Figure 8 This is a schematic diagram illustrating the connection between an embedded controller and a USB hub provided in an embodiment of this application. (Refer to...) Figure 8 The embedded controller 204 is connected to the EN (enable) pin of the USB hub 202, and is used to send a reset level signal to the EN pin of the USB hub 202.
[0138] like Figure 8 As shown, the terminal device also includes a signal adjustment module, which includes a first filtering unit 41 and a voltage regulator unit 42. The first filtering unit 41 is connected to the embedded controller 204 and the USB hub 202 respectively, and is used to filter the reset level signal output by the embedded controller 204 to improve the anti-interference capability of the reset level signal output by the embedded controller 204 to the USB hub 202. One end of the voltage regulator unit 42 is connected to the first level signal terminal V5P0A_PG, and the other end of the voltage regulator unit is connected in the path between the embedded controller 204 and the USB hub 202, and is used to regulate the reset level signal output by the embedded controller 204 to improve the stability of the reset level signal output by the embedded controller 204 to the USB hub 202.
[0139] The first filtering unit 41 includes a first resistor R1 and a first capacitor C1. The first end of the first resistor R1 is connected to the embedded controller 204, and the second end of the first resistor R1 is connected to the first end of the first capacitor C1. The first end of the first capacitor C1 is also connected to the EN pin of the USB hub 202, and the second end of the first capacitor C1 is connected to the ground terminal GND. The voltage regulation unit 42 includes a Zener diode D1. The positive terminal of the Zener diode D1 is connected to the second end of the first resistor R1, and the negative terminal of the Zener diode D1 is connected to the first level signal terminal V5P0A_PG.
[0140] In addition, the USB hub 202 also includes an input pin IN, an output pin OUT, and a ground pin GND. The input pin is connected to the input power supply terminal V5P0A, the output pin OUT is connected to the USB port, and the ground pin GND is connected to the ground terminal GND.
[0141] The terminal device further comprises a second filtering unit 43, one end of the second filtering unit 43 is connected to a path between the input power terminal V5P0A and the input pin IN of the USB hub, the other end of the second filtering unit 43 is connected to the ground terminal GND, and the second filtering unit 43 is used for filtering the power signal input to the USB hub 202 by the input power terminal V5P0A. The second filtering unit 43 comprises a second capacitor C2 and a third capacitor C3 connected in parallel, a first end of the second capacitor C2 is connected to the path between the input power terminal V5P0A and the input pin IN of the USB hub, a second end of the second capacitor C2 is connected to the ground terminal GND, a first end of the third capacitor C3 is connected to the path between the input power terminal V5P0A and the input pin IN of the USB hub, and a second end of the third capacitor C3 is connected to the ground terminal GND.
[0142] In step 313, when the USB device is successfully identified as the USB boot device, the processor loads the boot program file in the USB device through the USB hub.
[0143] When the processor successfully identifies the USB device as the USB boot device, it can be that the USB device is successfully identified as the USB boot device after software reset, or that the USB device is successfully identified as the USB boot device after hardware reset, and the processor reads and loads the boot program file in the USB device through the USB hub, re-installs the operating system of the terminal device based on the boot program file, or repairs the operating system of the terminal device.
[0144] If the fault repair program is used to repair the fault of the operating system, the boot program file actually refers to the fault repair program file; if the operating system is re-installed to repair the fault of the operating system, the boot program file actually refers to the program for booting the terminal device to re-install the operating system.
[0145] In summary, when the processor in the terminal device fails to successfully identify the USB device as the USB boot device, the embodiment of the application can first reset the USB device through the software reset mode, and when the USB device still cannot be identified, the USB device is reset through at least one hardware reset mode. Through software reset and hardware reset, the operation of manually plugging and unplugging the USB device is simulated, and the identification of the USB device can be restored without manual intervention, simplifying the operation of the user and improving the user experience.
[0146] Correspondingly, the software and hardware reset methods described in this application embodiment can also be used to detect whether the terminal device is malfunctioning, thereby improving problem-solving efficiency. For example, if the USB device can be recognized normally after the operating system starts up, but cannot be recognized normally during the boot process, the user may mistakenly believe that the motherboard of the terminal device is malfunctioning. However, in this application embodiment, the USB device is not recognized normally during the initial recognition process, but can be recognized normally after software and hardware resets. This indicates that the motherboard of the terminal device is not malfunctioning, but rather that the interface standard of the USB port of the terminal device is incompatible with the interface standard of the USB device.
[0147] For example, Figure 9 A flowchart illustrating another method for identifying a USB device provided in an embodiment of this application. (Refer to...) Figure 9 As shown, the method for a terminal device to identify a USB device may include the following steps:
[0148] Step 901: During the power-on process of the terminal device, the processor detects whether the user has pressed the second boot shortcut key.
[0149] A power button and a second boot shortcut key are provided on the keyboard 205. The embedded controller 204 detects the user's press operations on each key on the keyboard 205. When the user presses the power button, the embedded controller 204 detects the user's press operation and sends a power-on request to the processor 201. The processor 201 executes the power-on operation according to the power-on request sent by the embedded controller 204, causing the terminal device to start up.
[0150] During the power-on process of the terminal device, the embedded controller 204 detects whether the user has pressed the second startup shortcut key and sends the information on whether the second startup shortcut key has been pressed to the processor 201, thereby enabling the processor 201 to detect the pressing operation of the second startup shortcut key, that is, to detect whether the user has pressed the second startup shortcut key.
[0151] The second startup shortcut key can be the F12 key on the keyboard 205. It should be understood that the second startup shortcut key may be different for different models of terminal devices. In this embodiment, the second startup shortcut key can also be other keys on the keyboard 205.
[0152] Step 902: When the processor detects that the user has pressed the second boot shortcut key, the processor controls the display screen to show the boot option selection interface.
[0153] The second start shortcut key is taken as an example of F12 key. When the embedded controller 204 detects that the user presses the F12 key, the embedded controller 204 generates a second start request and sends the second start request to the processor. When the processor 201 receives the second start request sent by the embedded controller 204, the processor 201 can determine that the user presses the F12 key. Then, the processor 201 controls the display screen 206 to display a start item selection interface according to the second start request.
[0154] The start item selection interface at least includes a USB start item. Optionally, the start item selection interface further includes a hard disk start item and a network start item.
[0155] In step 903, when the processor detects that the user presses the start item selection key, the processor judges whether the selected start item is the USB start item.
[0156] The start item selection key is further arranged on the keyboard 205. If the user needs to start with the USB start item, the user moves the cursor to the position of the USB start item in the start item selection interface, and then presses the start item selection key. When the embedded controller 204 detects that the user presses the start item selection key, the embedded controller 204 generates a start item selection request, which includes the start item selected by the cursor when the start item selection key is pressed. The embedded controller 204 sends the start item selection request to the processor 201. When the processor 201 receives the start item selection request sent by the embedded controller 204, the processor 201 can determine that the user presses the start item selection key. Then, the processor judges whether the selected start item is the USB start item according to the start item selection request, that is, judges whether to start with the USB start item.
[0157] The start item selection key can be the Enter key in the keyboard 205. It should be understood that the start item selection key corresponding to different models of terminal devices can be different. The start item selection key in the embodiment of the application can also be other keys on the keyboard 205.
[0158] In step 904, when the selected start item is the USB start item, the processor loads the BIOS USB boot program.
[0159] In step 905, the processor detects whether a USB device is inserted into the USB port.
[0160] In step 906, when the USB device is inserted into the USB port, the processor performs an initialization operation on the USB port.
[0161] In step 907, the processor performs a configuration operation on the USB device.
[0162] Step 908, the processor detects whether the USB device is successfully identified as the USB boot device.
[0163] Step 909, when the USB device is not successfully identified as the USB boot device for the first time, the processor controls the USB hub to send a reset instruction to the USB device for software reset.
[0164] Step 910, when the USB device is not successfully identified as the USB boot device for the first time, the processor controls the embedded controller to send at least one reset level signal to the USB hub to reset the USB device in hardware.
[0165] Step 911, when the USB device is successfully identified as the USB boot device, the processor loads the boot program file in the USB device through the USB hub.
[0166] Figure 9 The specific execution process of steps 904 to 911 is similar to the above Figure 3 The specific execution process of steps 306 to 313 is similar, and details are not repeated here,
[0167] It can be understood that, Figure 9 The process of starting with the USB boot item does not need to change the starting order of each boot item in the boot item list, and Figure 3 The process of starting with the USB boot item needs to change the starting order of each boot item in the boot item list, and set the USB boot item as the first boot item in the boot item list.
[0168] In summary, when the processor in the terminal device does not successfully identify the USB device as the USB boot device, the embodiment of the application can first reset the USB device through the software reset method, and when it is still not possible to identify the USB device, the USB device is reset through at least one hardware reset method. By software reset and hardware reset, the operation of manually plugging in the USB device is simulated, and it is possible to restore the identification of the USB device without manual intervention, simplifying the user's operation and improving the user's experience.
[0169] The terminal device in the embodiment of the application can be a notebook computer, a tablet computer, and can also be a desktop computer, an all-in-one machine, and the like, and can also be other electronic devices that need to be operated through a USB boot device for operating system repair or reinstallation.
[0170] In the embodiment of the present application, the terminal device comprises a hardware layer, an operating system layer running above the hardware layer, and an application layer running on the operating system layer. The hardware layer comprises hardware such as a central processing unit, a memory management unit (MMU), and a memory (also referred to as main memory). The operating system can be any one or more computer operating systems that implement business processing through processes, such as a Linux operating system, a Unix operating system, or a windows operating system. The application layer comprises applications such as a browser, an address book, word processing software, and instant messaging software.
[0171] The USB device identification method of the embodiment of the present application has been described above, and the device for executing the USB device identification method provided by the embodiment of the present application is described below. Those skilled in the art can understand that the method and the device can be combined and referenced with each other, and the USB device identification device provided by the embodiment of the present application can execute the steps in the USB device identification method.
[0172] Figure 10 The hardware structure schematic diagram of the USB device identification device provided by the embodiment of the present application is shown in FIG. 2. Referring to FIG. 2, Figure 10 The device can be deployed in a terminal device, and the device comprises a memory 209, a processor 201, an interface circuit 210, an embedded controller 204, a USB hub 202, and a USB port 203, wherein the memory 209, the processor 201, and the interface circuit 210 can communicate, for example, the memory 209, the processor 201, and the interface circuit 210 can communicate through a communication bus; the processor 201 can also communicate with the embedded controller 204 and the USB hub 202, the embedded controller 204 can communicate with the USB hub 202, and the USB hub 202 can communicate with the USB port 203.
[0173] The memory 209 can be a read-only memory, a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 209 can store a computer program, which is controlled by the processor 201 to execute, and is executed by the interface circuit 210 to perform communication, thereby implementing the USB device identification method provided by the embodiment of the present application.
[0174] In a possible implementation manner, the computer execution instruction in the embodiment of the present application can also be referred to as an application program code, which is not specifically limited in the embodiment of the present application.
[0175] Optionally, the interface circuit 210 can further include a transmitter and / or a receiver. Optionally, the processor 201 can be a general purpose processor, a microprocessor, an application specific integrated circuit (ASIC), a graphics processing unit (GPU) or one or more integrated circuits.
[0176] The processor 201 can also be an integrated circuit chip with a signal processing capability. In implementation, the functions of the USB device identification of the present application can be completed by hardware integrated logic circuit or software form of instructions in the processor 201. The processor 201 can also be a general purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, which can realize or execute the methods, steps and logical block diagrams disclosed in the embodiments of the present application. The general purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the methods disclosed in the embodiments of the present application can be directly embodied as a hardware code processor to execute, or be executed by a combination of hardware and software modules in the code processor. The software module can be located in a random access memory, a flash memory, a read only memory, a programmable read only memory or an electrically erasable programmable memory, a register, or other mature storage medium in the art. The storage medium is located in the memory 209, and the processor 201 reads the information in the memory 209 and combines the hardware to complete the functions of the USB device identification of the embodiments of the present application.
[0177] The embodiments of the present application further provide a computer readable storage medium. The methods described in the above embodiments can be realized by software, hardware, firmware or any combination thereof, in whole or in part. If realized in software, the functions can be stored or transmitted as one or more instructions or codes on a computer readable medium. The computer readable medium can include a computer storage medium and a communication medium, and can further include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium that can be accessed by a computer.
[0178] In a possible implementation, the computer readable medium can include RAM, ROM, a compact disc read-only memory (CD-ROM) or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that is suitable for storing desired program code in the form of instructions or data structures and that can be accessed by a computer. Also, any connection is properly termed a computer readable medium. For example, if the software is transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. Disk and disc, as used herein, include compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk and Blu-ray® disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer readable media.
[0179] The embodiments of the present application are described with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as a combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the computer or other programmable data processing apparatus generate a device that implements the functions specified in the flowchart and / or block diagram block or blocks. Figure 1 The functions of one or more flows or blocks in the flowchart and / or block diagram Figure 1 The functions of one or more flows or blocks in the flowchart and / or block diagram
[0180] The above detailed description has further explained the purpose, technical solutions and beneficial effects of the present application. It should be understood that the above is only a specific implementation of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made on the basis of the technical solutions of the present application should be included in the protection scope of the present application.
Claims
1. A method of identifying a USB device, characterized by, The method is applied to a terminal device having a USB port, and comprises the following steps: In the process of starting up the terminal device, it is determined whether to start up with a USB start item; When starting up with the USB start item, it is determined whether a USB device is inserted into the USB port; When a USB device is inserted into the USB port, it is determined whether the USB device is successfully identified as a USB start device; the USB device comprises a boot program file for repairing or reinstalling an operating system; When the USB device is not successfully identified as the USB start device, a software reset operation is performed, and it is determined again whether the USB device is successfully identified as the USB start device; When the USB device is not successfully identified as the USB start device, a hardware reset operation is performed, and it is determined again whether the USB device is successfully identified as the USB start device; When the USB device is successfully identified as the USB start device, the boot program file in the USB device is loaded; The terminal device comprises a processor, an embedded controller and a USB hub connected in sequence; the hardware reset operation comprises the following steps: The processor controls the embedded controller to send a reset level signal to the USB hub; the reset level signal comprises a low level signal and a high level signal after an interval of a preset time length; the processor controls the embedded controller to send the reset level signal for multiple times, and the preset time length corresponding to the reset level signal sent for the N+1th time is greater than the preset time length corresponding to the reset level signal sent for the Nth time, wherein N is a positive integer; The terminal device comprises a processor and a USB hub connected to each other, and the USB hub is connected to the USB port; the determination of whether the USB device is successfully identified as the USB start device comprises the following steps: The processor sends a port state acquisition instruction to the USB hub; The processor receives a port state of the USB port returned by the USB hub according to the port state acquisition instruction; When the port state is a busy state, the processor sends a port state clearing instruction to the USB hub to clear the port state of the USB port; The processor sends a write port state instruction to the USB hub, so that the USB hub sends a reset instruction to the USB device and sets the port state of the USB port to an idle state; The processor performs a configuration operation on the USB device through the USB hub; It is detected whether a file system type of the USB device and a boot program file type corresponding to the boot program file are read from the USB device.
2. The method of claim 1, wherein, The software reset operation comprises the following steps: The processor controls the USB hub to send a reset instruction to the USB device.
3. The method of claim 1, wherein, After the software reset operation is performed and it is determined again whether the USB device is successfully identified as the USB start device, the following steps are further included: When the USB device is not successfully identified as the USB boot device, at least one software reset operation is continuously performed, and whether the USB device is successfully identified as the USB boot device is determined after each software reset operation.
4. The method of claim 1, wherein, After the hardware reset operation is performed and whether the USB device is successfully identified as the USB boot device is continuously determined, the method further comprises: When the USB device is still not successfully identified as the USB boot device, at least one hardware reset operation is continuously performed, and whether the USB device is successfully identified as the USB boot device is determined after each hardware reset operation.
5. The method of claim 1, wherein, The preset time length corresponding to the reset level signal sent for the N+1th time is M times of the preset time length corresponding to the reset level signal sent for the Nth time, and the M is a positive integer greater than 1.
6. The method of claim 1, wherein, The determining whether a USB device is inserted into the USB port comprises: The processor receives a connection state reported by the USB hub; The processor determines whether a USB device is inserted into the USB port according to the connection state.
7. The method of claim 1, wherein, The processor performs a configuration operation on the USB device through the USB hub, comprising: The processor sends a device descriptor acquisition instruction to the USB device through the USB hub; The processor receives a device descriptor returned by the USB device according to the device descriptor acquisition instruction; When a field in the device descriptor corresponds to a storage device, the processor sends a configuration descriptor acquisition instruction to the USB device through the USB hub; The processor receives a configuration descriptor returned by the USB device according to the configuration descriptor acquisition instruction; When a field in the configuration descriptor corresponds to a U disk, the processor sends a configuration instruction to the USB device through the USB hub to set the USB device to a configuration state.
8. The method of claim 1, wherein, The terminal device comprises a processor, an embedded controller, a keyboard and a display screen, the keyboard is connected with the embedded controller, the embedded controller is connected with the processor, the display screen is connected with the processor, and the keyboard comprises a first start shortcut key, a start item moving key and a start item saving key. Before the determining whether to start with the USB start item, the method further comprises: During the starting process of the terminal device, when the processor receives a first start request for a BIOS setting interface sent by the embedded controller, the processor controls the display screen to display the BIOS setting interface; the first start request is generated by the embedded controller when detecting a pressing operation on the first start shortcut key, and the BIOS setting interface comprises a start item list, and the start item list comprises a hard disk start item, a USB start item and a network start item. When the processor receives the order change request for the startup item list sent by the embedded controller, the processor changes the order of each startup item in the startup item list; the order change request is generated by the embedded controller when detecting the pressing operation of the startup item moving key; When the processor receives the save request for the startup item list sent by the embedded controller, the processor saves the startup item list; the save request is generated by the embedded controller when detecting the pressing operation of the startup item save key; The method further comprises: In the process of restarting the terminal device, the processor judges whether the first startup item in the saved startup item list is the USB startup item.
9. The method of claim 1, wherein, The terminal device comprises a processor, an embedded controller, a keyboard and a display screen, the keyboard is connected with the embedded controller, the embedded controller is connected with the processor, the display screen is connected with the processor, and the keyboard comprises a second startup shortcut key and a startup item selection key. The method further comprises: In the process of starting up the terminal device, when the processor receives the second startup request for the startup item selection interface sent by the embedded control, the processor controls the display screen to display the startup item selection interface; the second startup request is generated by the embedded controller when detecting the pressing operation of the second startup shortcut key, and the startup item selection interface at least comprises a USB startup item. When the processor receives the startup item selection request sent by the embedded controller, the processor determines whether the selected startup item is a USB startup item according to the startup item selection request; the startup item selection request is generated by the embedded controller when detecting the pressing operation of the startup item selection key.
10. A terminal device, comprising: The terminal device comprises a processor and a memory; The memory stores computer execution instructions; The processor is configured to execute the computer execution instructions stored in the memory, so that the processor performs the identification method of the USB device according to any one of claims 1 to 9.
11. The terminal device according to claim 10, characterized by The terminal device further comprises a signal adjustment module, and the signal adjustment module comprises a first filtering unit and a voltage stabilizing unit; The first filtering unit is connected with the embedded controller and the USB hub respectively, and is configured to perform filtering processing on the reset level signal output by the embedded controller; One end of the voltage stabilizing unit is connected with the first level signal end, and the other end of the voltage stabilizing unit is connected in the path between the embedded controller and the USB hub, and is configured to perform voltage stabilizing processing on the reset level signal output by the embedded controller.
12. The terminal device according to claim 11, characterized by The first filter unit comprises a first resistor and a first capacitor; a first end of the first resistor is connected with the embedded controller, a second end of the first resistor is connected with a first end of the first capacitor, the first end of the first capacitor is also connected with the USB hub, and a second end of the first capacitor is connected with a ground end; The voltage stabilizing unit comprises a voltage stabilizing diode; a positive electrode of the voltage stabilizing diode is connected with the second end of the first resistor, and a negative electrode of the voltage stabilizing diode is connected with the first level signal end.
13. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program or instructions, and when the computer program or instructions are run, the identification method of the USB device as claimed in any one of claims 1 to 9 is implemented.
14. A system for identifying a USB device, the system comprising: The system comprises a USB device and a terminal device as claimed in any one of claims 10 to 12, and the USB device stores a boot program file.
Citation Information
Patent Citations
Board reset method and device
CN105022467A
USB device control method and the apparatus
KR1020080040457A