1| Supported Targets | ESP32-S2 | ESP32-S3 | 2| ----------------- | -------- | -------- | 3 4# TinyUSB Sample Descriptor 5 6(See the README.md file in the upper level 'examples' directory for more information about examples.) 7 8This example is demonstrating how to set up ESP chip to work as a Generic USB Device with a user-defined descriptor. You can specify a manufacturer, device's name, ID and other USB-devices parameters responsible for identification by host. 9 10As a USB stack, a TinyUSB component is used. 11 12## How to use example 13 14### Hardware Required 15 16Any ESP boards that have USB-OTG supported. 17 18#### Pin Assignment 19 20See common pin assignments for USB Device examples from [upper level](../README.md#common-pin-assignments). 21 22### Configure the project 23 24There are two ways to set up a descriptor - using Menuconfig tool and in-code 25 26#### In-code setting up 27 28For the manual descriptor configuration use the default example's settings and modify `my_descriptor` in [source code](main/tusb_sample_descriptor_main.c) according to your needs 29 30#### Menuconfig 31 32If you want to set up the descriptor using Menuconfig UI: 33 341. Execute in the terminal from the example's directory: `idf.py menuconfig` 35 362. Turn off `Set up a USB descriptor manually in code` parameter at `Example Configuration` 37 383. Follow `Component config -> TinyUSB -> Descriptor configuration` for all available configurations. 39 40### Build and Flash 41 42Build the project and flash it to the board, then run monitor tool to view serial output: 43 44```bash 45idf.py -p PORT flash monitor 46``` 47 48(Replace PORT with the name of the serial port to use.) 49 50(To exit the serial monitor, type ``Ctrl-]``.) 51 52See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects. 53 54## Example Output 55 56After the flashing you should see the output: 57 58``` 59I (287) example: USB initialization 60I (287) tusb_desc: 61┌─────────────────────────────────┐ 62│ USB Device Descriptor Summary │ 63├───────────────────┬─────────────┤ 64│bDeviceClass │ 0 │ 65├───────────────────┼─────────────┤ 66│bDeviceSubClass │ 0 │ 67├───────────────────┼─────────────┤ 68│bDeviceProtocol │ 0 │ 69├───────────────────┼─────────────┤ 70│bMaxPacketSize0 │ 64 │ 71├───────────────────┼─────────────┤ 72│idVendor │ 0x303a │ 73├───────────────────┼─────────────┤ 74│idProduct │ 0x3000 │ 75├───────────────────┼─────────────┤ 76│bcdDevice │ 0x101 │ 77├───────────────────┼─────────────┤ 78│iManufacturer │ 0x1 │ 79├───────────────────┼─────────────┤ 80│iProduct │ 0x2 │ 81├───────────────────┼─────────────┤ 82│iSerialNumber │ 0x3 │ 83├───────────────────┼─────────────┤ 84│bNumConfigurations │ 0x1 │ 85└───────────────────┴─────────────┘ 86I (457) TinyUSB: TinyUSB Driver installed 87I (467) example: USB initialization DONE 88``` 89 90From PC, running `lsusb -v`, you should find the device's descriptor like: 91``` 92Bus 001 Device 007: ID 303a:3000 I My Custom Device 93Device Descriptor: 94 bLength 18 95 bDescriptorType 1 96 bcdUSB 2.00 97 bDeviceClass 0 98 bDeviceSubClass 0 99 bDeviceProtocol 0 100 bMaxPacketSize0 64 101 idVendor 0x303a 102 idProduct 0x3000 103 bcdDevice 1.01 104 iManufacturer 1 I 105 iProduct 2 My Custom Device 106 iSerial 3 012-345 107 bNumConfigurations 1 108 Configuration Descriptor: 109 bLength 9 110 bDescriptorType 2 111 wTotalLength 0x0009 112 bNumInterfaces 0 113 bConfigurationValue 1 114 iConfiguration 0 115 bmAttributes 0xa0 116 (Bus Powered) 117 Remote Wakeup 118 MaxPower 100mA 119can't get device qualifier: Resource temporarily unavailable 120can't get debug descriptor: Resource temporarily unavailable 121Device Status: 0x0000 122 (Bus Powered) 123``` 124