USB enumeration and descriptor sending sequence Parsing

Source: Internet
Author: User

I. Detailed analysis of mcb1700 USB library files:

Mcb1700 has many USB files, but you just need to figure out a few:

1. mscuser. c large-capacity storage device-related files, such as the read/write design to the storage device, and the protocol used. For example, SD card, bot protocol (CBW, CSW parsing, SCSI Command Parsing ).

2. usbdesc. c USB device descriptor, configuration descriptor, interface descriptor, endpoint Descriptor (bulk-in endpoint and bulk-out endpoint)

3. Some hardware registers of usbhw. c USB are obtained.
The main function is void usb_irqhandler (void) {}. You can view the USB status during a USB interrupt and call the processing functions of each endpoint to process the corresponding data packets.

4. USB core. C. The core part of the USB software, including the USB status, the request to obtain various descriptors and other functions. For more information, see void usb_endpoint0 (u32 event) {}. The default endpoint 0 is used for communication during enumeration. Therefore, USB devices are generally required.

5. USB user. C. The function defined by USB developers is mainly an endpoint function other than the endpoint 0 Function for calling the interrupt function in 3.

Ii. Data Analysis of setup package (see the following document for printed data)
Where:
1) sup: 80 6 0 1 0 0 40 0 indicates the data received in the first setup package. 40 indicates that the maximum length of the returned data is 40 h. The device descriptor (8 + 8) with a total of 16 bytes will be sent ).
2) sup: 0 5 1 0 0 0 0 0 indicates the data received in the second setup package
3) sup: 80 6 0 1 0 0 12 0 third
4) sup: 80 6 0 2 0 0 9 0
5) sup: 80 6 0 3 0 0 FF 0
......
N) sup: 0 9 1 0 0 0 0 0

Explanation:
1) indicates the data received in the first setup package. 40 indicates that the maximum length of the returned data is 40 h. The device descriptor (8 + 8) with a total of 16 bytes will be sent ).
2) indicates the data received in the second setup package. 1 indicates that the address allocated by the host for the device is 0x02.
3) third. 12 h indicates that the device descriptor of all 18 bytes is required.
4) The configuration descriptor of the device must be obtained in 9 bytes.
5) obtain the configuration descriptor, interface descriptor, and Endpoint descriptor set of the device.
......
N) Call the set_configuration function.

Iii. Other Instructions
1. 0.1 USB _ evt_setup package with the endpoint 0
2. 0.2 USB _ evt_out package with endpoint 0
3. 0.3 USB _ evt_in package with endpoint 0
4. W n: n data records to be written to a port
5. 0.1.1.1 special information. The usb_msc setting request is complete.
6. 2 3 usb_evt_out package of endpoint 2
7.2 2 usb_evt_in package of endpoint 2

Iv. Notes

I think the data in the USB interrupt cannot be printed too much, or the USB recognition process may be faulty.
When debugging, you only need to find that the value of the USB-> usbdevintst register is 0x5.
The general order of printing is as follows:
19 39 239 239 239 239 9 39 5 (in most cases)

Wait until this 5 is displayed.

V. Data
 
The entire process of USB recognition is printed as follows:

1) only setup and description
Sup: 80 6 0 1 0 0 40 0 0.1 get_descriptor: device_descriptor 0.3 0.2
Sup: 0 5 1 0 0 0 0 0 0.1 set_address: 0.3
Sup: 80 6 0 1 0 12 0 0.1 get_descriptor: device_descriptor 0.3 0.3 0.3
Sup: 80 6 0 2 0 9 0 0.1 get_descriptor: configuration_descriptor 0.3 0.3 0.2
Sup: 80 6 0 3 0 FF 0 0.1 get_descriptor: string_descriptor 0.3 0.2
Sup: 80 6 3 3 9 4 ff 0 0.1 get_descriptor: string_descriptor 0.3 0.3 0.3
Sup: 80 6 0 2 0 FF 0 0.1 get_descriptor: configuration_descriptor 0.3 0.3 0.3 0.3
Sup: 80 6 0 6 0 0 A 0 0.1 get_descriptor:
Sup: 80 6 0 3 0 FF 0 0.1 get_descriptor: string_descriptor 0.3 0.2
Sup: 80 6 2 3 9 4 ff 0 0.1 get_descriptor: string_descriptor 0.3 0.3 0.3 0.3 0.3 0.3
Sup: 80 6 0 3 0 FF 0 0.1 get_descriptor: string_descriptor 0.3
Sup: 80 6 2 3 9 4 ff 0 0.1 get_descriptor: string_descriptor 0.3 0.3 0.3 0.3 0.3 0.3
Sup: 80 6 0 1 0 12 0 0.1 get_descriptor: device_descriptor 0.3 0.3 0.3
Sup: 80 6 0 2 0 9 0 0.1 get_descriptor: configuration_descriptor 0.3 0.3 0.2
Sup: 80 6 0 2 0 20 0 0.1 get_descriptor: configuration_descriptor 0.3 0.3 0.3 0.3
Sup: 80 6 0 3 0 0 2 0 0.1 get_descriptor: string_descriptor 0.3 0.2
Sup: 80 6 0 3 0 0 4 0 0.1 get_descriptor: string_descriptor 0.3 0.2
Sup: 80 6 3 9 4 2 0 0.1 get_descriptor: string_descriptor 0.3 0.2
Sup: 80 6 3 3 9 4 1A 0 0.1 get_descriptor: string_descriptor 0.3 0.3 0.3
Sup: 0 9 1 0 0 0 0 0.1 set_configuration: 0.3
Sup: A1 Fe 0 0 0 0 1 0 0.1
0.1.1.1 0.2 0.3
Sup: 2 1 0 0 82 0 0 0.1 clear_feature: 0.3
Sup: 2 1 0 0 82 0 0 0.1 clear_feature: 0.3
Sup: 2 1 0 0 82 0 0 0.1 clear_feature: 0.3
Sup: 2 1 0 0 82 0 0 0.1 clear_feature: 0.3
Sup: 2 1 0 0 82 0 0 0.1 clear_feature: 0.3

2) Add a flag based on 1

USB test!
Sup: 80 6 0 1 0 0 40 0 0.1 get_descriptor: device_descriptor W 8: 0.3 W 8: 0.2
Sup: 0 5 1 0 0 0 0 0 0.1 set_address: w 0: 0.3
Sup: 80 6 0 1 0 12 0 0.1 get_descriptor: device_descriptor W 8: 0.3 W 8: 0.3 W 2: 0.3 W 0:
Sup: 80 6 0 2 0 9 0 0.1 get_descriptor: configuration_descriptor W 8: 0.3 W 1: 0.3 W 0: 0.2
Sup: 80 6 0 3 0 FF 0 0.1 get_descriptor: string_descriptor W 4: 0.3 W 0: 0.2
Sup: 80 6 3 9 4 ff 0 0.1 get_descriptor: string_descriptor W 8: 0.3 W 8: 0.3 W 8: 0.3 W 2: 0.3 W 0: 0.2
Sup: 80 6 0 2 0 FF 0 0.1 get_descriptor: configuration_descriptor W 8: 0.3 W 8: 0.3 W 8: 0.3 W 8: 0.3 W 0: 0.3 W 0:
Sup: 80 6 0 6 0 0 A 0 0.1 get_descriptor:
Sup: 80 6 0 3 0 FF 0 0.1 get_descriptor: string_descriptor W 4: 0.3 W 0:
Sup: 80 6 2 3 9 4 ff 0 0.1 get_descriptor: string_descriptor W 8: 0.3 W 8: 0.3 W 8: 0.3 W 8: 0.3 W 8: 0.3 W 0: 0.3 W 0:
Sup: 80 6 0 3 0 FF 0 0.1 get_descriptor: string_descriptor W 4: 0.3 W 0:
Sup: 80 6 2 3 9 4 ff 0 0.1 get_descriptor: string_descriptor W 8: 0.3 W 8: 0.3 W 8: 0.3 W 8: 0.3 W 8: 0.3 W 0: 0.3 W 0: 0.2
Sup: 80 6 0 1 0 12 0 0.1 get_descriptor: device_descriptor W 8: 0.3 W 8: 0.3 W 2: 0.3 W 0: 0.2
Sup: 80 6 0 2 0 9 0 0.1 get_descriptor: configuration_descriptor W 8: 0.3 W 1: 0.3 W 0:
Sup: 80 6 0 2 0 20 0 0.1 get_descriptor: configuration_descriptor W 8: 0.3 W 8: 0.3 W 8: 0.3 W 8: 0.3 W 0:
Sup: 80 6 0 3 0 0 2 0 0.1 get_descriptor: string_descriptor W 2: 0.3 W 0:
Sup: 80 6 0 3 0 0 4 0 0.1 get_descriptor: string_descriptor W 4: 0.3 W 0:
Sup: 80 6 3 9 4 2 0 0.1 get_descriptor: string_descriptor W 2: 0.3 W 0:
Sup: 80 6 3 3 9 4 1A 0 0.1 get_descriptor: string_descriptor W 8: 0.3 W 8: 0.3 W 8: 0.3 W 2: 0.3 W 0:
Sup: 0 9 1 0 0 0 0 0.1 set_configuration: w 0: 0.3
Sup: A1 Fe 0 0 0 1 0 0.1 W 1:
0.1.1.1 0.2 0.3 W 0: 2 2 W 36: 2 3 W 13: 2 3 2 2 W 12: 2 3 W 13:
Sup: 2 1 0 82 0 0 0 0 0.1 clear_feature: W 13: w 0: 0.3 2 2 2 W 8: 2 3 W 13: 2 3 2 2 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 13: 2 3 2 W 4: 2 3 W 13:
Sup: 2 1 0 82 0 0 0 0.1 clear_feature: W 13: w 0: 0.3 2 3 2 W 4: 2 3 W 13:
Sup: 2 1 0 82 0 0 0 0 0.1 clear_feature: W 13: w 0: 0.3 2 2 2 W 8: 2 3 W 13: 2 3 2 2 W 8: 2 3 W 13: 2 3 2 2 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 13: 2 3 2 2 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 13: 2 3 2 2 W 8: 2 3 W 13: 2 3 2 W 8: 2 3 W 13: 2 3 2 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 13: 2 3 2 2 W 13: 2 3 2 W 13: 2 3 2 2 W 18: 2 3 W 13: 2 3 2 W 13: 2 3 2 2 W 18: 2 3 W 13: 2 3 2 2 W 13: 2 3 2 2 W 18: 2 3 W 13: 2 3 2 W 13: 2 3 2 2 W 18: 2 3 W 13: 2 3 2 2 W 13: 2 3 2 W 18: 2 3 W 13: 2 3 2 W 4: 2 3 W 13:
Sup: 2 1 0 82 0 0 0 0 0.1 clear_feature: W 13: w 0: 0.3 2 2 2 W 8: 2 3 W 13: 2 3 2 2 W 8: 2 3 W 13: 2 3 2 2 W 8: 2 3 W 13: 2 3 2 2 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 13: 2 3 2 2 W 13: 2 3 2 W 18: 2 3 W 13: 2 3 2 2 W 13: 2 3 2 W 18: 2 3 W 13: 2 3 2 2 W 13: 2 3 2 W 18: 2 3 W 13: 2 3 2 2 W 13: 2 3 2 W 18: 2 3 W 13: 2 3 2 2 W 13: 2 3 2 W 18: 2 3 W 13: 2 3 2 2 W 8: 2 3 W 13: 2 3 2 2 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 13: 2 3 2 2 W 8: 2 3 W 13: 2 3 2 2 W 13: 2 3 2 W 8: 2 3 W 13: 2 3 2 2 W 8: 2 3 W 13: 2 3 2 W 8: 2 3 W 13: 2 3 2 2 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 13: 2 3 2 2 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 64: 2 3 W 13: 2 3 2 2 W 4: 2 3 W 13:
Sup: 2 1 0 82 0 0 0 0 0.1 clear_feature: W 13: w 0: 0.3 2 2 2 W 13: 2 3 2 W 13: 2 3 2 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 3 2 W 13: 2 3 2 W 13: 2 3 2 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 3 2 W 13: 2 3 2 W 13: 2 3 2 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 3 2 W 13: 2 3 2 W 13: 2 3 2 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 3 2 W 13: 2 3 2 W 13: 2 3 2 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 3 2 W 13: 2 3 2 W 13: 2 3 2 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 3 2 W 13: 2 3 2 W 13: 2 3 2 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 3 2 W 13: 2 3 2 W 13: 2 3 2 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 3 2 W 13: 2 3 2 W 13: 2 3 2 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3 3 2 W 13: 2 3 2 W 13: 2 3 2 2 W 13: 2 3 2 W 13: 2 3 2 W 13: 2 3

3) 2. Add printed data

Sup: 80 6 0 1 0 0 40 0 0.1 get_descriptor: device_descriptor W 8: 2000112 8000000 0.3 W 8: 2203c00002010100
Sup: 0 5 1 0 0 0 0 0 0.1 set_address: w 0: 0.3
Sup: 80 6 0 1 0 12 0 0.1 get_descriptor: device_descriptor W 8: 2000112 8000000 0.3 W 8: 2203c00002010100 0.3 W 2: 103 0.3 W 0:
Sup: 80 6 0 2 0 9 0 0.1 get_descriptor: configuration_descriptor W 8: 200209 80000101 0.3 W 1: 40932 0.3 W 0:
Sup: 80 6 0 3 0 FF 0 0.1 get_descriptor: string_descriptor W 4: 4090304 0.3 W 0:
Sup: 80 6 3 9 4 ff 0 0.1 get_descriptor: string_descriptor W 8: 30031a 300030 0.3 W 8: 410031 300030 0.3 W 8: 300030 300030 0.3 W 2: 30e0030 0.3 W 0:
Sup: 80 6 0 2 0 FF 0 0.1 get_descriptor: configuration_descriptor W 8: 200209 80000101 0.3 W 8: 40932 6080200 0.3 W 8: 5070450 400282 0.3 W 8: 2050700 4002 0.3 W 0: 0.3 W 0:
Sup: 80 6 0 6 0 0 A 0 0.1 get_descriptor:
Sup: 80 6 0 3 0 FF 0 0.1 get_descriptor: string_descriptor W 4: 4090304 0.3 W 0:
Sup: 80 6 2 3 9 4 ff 0 0.1 get_descriptor: string_descriptor W 8: 4b0328 690065 0.3 W 8: 20006c 43004d 0.3 W 8: 310042 300037 W 8: 200030 65004d 0.3 W 8: 6f006d 790072 0.3 W 0: 0.3 W 0: 0.2
Sup: 80 6 0 3 0 FF 0 0.1 get_descriptor: string_descriptor W 4: 4090304 0.3 W 0:
Sup: 80 6 2 3 9 4 ff 0 0.1 get_descriptor: string_descriptor W 8: 4b0328 690065 0.3 W 8: 20006c 43004d 0.3 W 8: 310042 300037 W 8: 200030 65004d 0.3 W 8: 6f006d 790072 0.3 W 0: 0.3 W 0: 0.2
Sup: 80 6 0 1 0 12 0 0.1 get_descriptor: device_descriptor W 8: 2000112 8000000 0.3 W 8: 2203c00002010100 0.3 W 2: 103 0.3 W 0:
Sup: 80 6 0 2 0 9 0 0.1 get_descriptor: configuration_descriptor W 8: 200209 80000101 0.3 W 1: 40932 0.3 W 0:
Sup: 80 6 0 2 0 20 0 0.1 get_descriptor: configuration_descriptor W 8: 200209 80000101 0.3 W 8: 40932 6080200 0.3 W 8: 5070450 400282 0.3 W 8: 2050700 4002 0.3 W 0:
Sup: 80 6 0 3 0 0 2 0 0.1 get_descriptor: string_descriptor W 2: 4090304 0.3 W 0:
Sup: 80 6 0 3 0 0 4 0 0.1 get_descriptor: string_descriptor W 4: 4090304 0.3 W 0: 0.2
Sup: 80 6 3 9 4 2 0 0.1 get_descriptor: string_descriptor W 2: 30031a 0.3 W 0:
Sup: 80 6 3 9 4 1A 0 0.1 get_descriptor: string_descriptor W 8: 30031a 300030 0.3 W 8: 410031 300030 0.3 W 8: 300030 300030 0.3 W 2: 30e0030 0.3 W 0:
Sup: 0 9 1 0 0 0 0 0.1 set_configuration: w 0: 0.3
Sup: A1 Fe 0 0 0 1 0 0.1 W 1: 3030600
0.1.1.1 0.2 0.3 W 0: 2 2 W 36: 1008000 ......

Note:
1) To facilitate browsing, use the ultraedit tool to open the above documents.
2) If you have any questions, email mary0515 # gmail.com to discuss them together.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.