What happens when the PC recognizes the USB device?
Ben Eater explains on blogs and YouTube the operation of electronic devices, what kind of processing is done on the PC when a USB device is connected to the USB port that is installed as standard on a general PC. He explains in the video.
Mr. Eater used a DELL keyboard for connection. The oscilloscope is for analyzing communication content.
When the PC detects a device, it first detects whether the device is slow or fast.
Looking at the oscilloscope, 'D-' is at a high level for low-speed devices, and 'D +' is at a high level for high-speed devices. Then, after resetting the recognition once, the PC will start communicating with the device.
Let's enlarge the waveform. When the device is first connected, the device sends a setup packet to the PC. Both the target ID address and the endpoint are displayed as 0 because no target ID address has been assigned to the device at this stage. Setup is done using this 0 address and then the data is sent.
Subsequent setup data will be identified according to a specific format for each device. The packet this time is '00 05 0C 00 00 00 00 00'. It is written in hexadecimal.
The first byte represents the request type.
In the case of the keyboard connected this time, bmRequestType is '00', so it will be 00000000 in binary notation. This is further grouped by bits such as D7, D6 / D5, D4 to D0 and converted to decimal numbers. Looking at the table, D7 is 0, so 'a packet was sent from the host PC to the device', D6D5 is also 0, so 'it is a standard request', and D4 to D0 are also 0, so 'the recipient is the device' You can see that it points to 'being.'
The next 1 byte (05) means that it is a specific request (bRequest). If you check it, there is a description that 'Please refer to Table 9-3'.
Since the value of bRequest is '05', you can see that the content is 'SET_ADDRESS'.
Next, check the 'wValue', 'wINdex', and 'wLength' values indicated by the request.
wValue, wIndex, and wLength are all 2 bytes.
Looking at the oscilloscope, in this case wValue is '0C 00' and wINdex and wLength are '00 00'.
All three have specific requests, so let's take a look. wValue represents 'Device Address'.
The wValue is '0C 00', which means that they are sorted during conversion, so they are actually '000C', that is, the 'Device Address' is 'C'.
wINdex and wLength are 'Zero' in this case.
Try running the lsusb command on your PC. All USB devices are displayed, but you can see that the device '12 (C in hexadecimal)' is detected in it. The DELL keyboard I just connected seems to have been detected successfully as I saw it on the oscilloscope.
The setup command is assigned C and is 0C, and the endpoint is 0 by default.
Of course, there are also packets sent from the USB keyboard to your computer.
After the USB device sends a packet to the PC, the request returned from the PC to the device is '6'.
'6' is 'GET_DESCRIPTOR', which means that the PC is requesting a descriptor from the device. The device in your computer does not know what it is when it recognizes the USB device. It could be a mouse or it could be a hard drive. That's why the PC is asking the device for a descriptor that explains what it is.
The number that follows is '10 01'. This indicates that the connected device is USB 1.1.
It also identifies the manufacturer and product serial number.
Eater also provides more specialized commentary. Also, the USB specifications that Mr. Eater has can be downloaded from the distribution page of the USB Implementers Forum , so please check it if you are interested.
Related Posts: