Greetings folks,
I am trying to set up an ESP32-S3 as a USB *device* with the following interfaces:
* USB HID
* USB CDC
I looked through the examples and did my best, and the result is the attached program. When I connect this to my Ubuntu Linux system, and run "usb-devices", I get the following:
S: Manufacturer=Airball.aero
S: Product=Knob+CANBus peripheral
S: SerialNumber=123456
C: #Ifs= 3 Cfg#= 1 Atr=a0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=usbhid
E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=10ms
I: If#= 1 Alt= 0 #EPs= 0 Cls=02(commc) Sub=02 Prot=00 Driver=(none)
I: If#= 2 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=(none)
E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
E: Ad=83(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
Note that If#=1 has zero endpoints, when it should have 1 endpoint. Perhaps as a result, the "cdc_acm" driver is not binding to this interface. What am I doing wrong?
Ihab
Please help me debug USB descriptors
Please help me debug USB descriptors
- Attachments
-
- knob_main.c
- (3.87 KiB) Downloaded 116 times
Re: Please help me debug USB descriptors
Here are some more results, isolated for clarity. Note that, in the code, I am merely commenting out certain areas, and changing the number of interfaces, to clarify what is being changed. My question is, if Case A and Case B work, then why does Case C not work?
CASE A: ONE HID INTERFACE (works correctly)
Result from "usb-devices":
CASE B: ONE CDC INTERFACE (works correctly)
Result from "usb-devices":
Additionally, the Linux system correctly shows a device, "/dev/ttyACM0".
CASE C: ONE HID AND ONE CDC INTERFACE (does not work)
Result from "usb-devices":
I see no suspicious error messages in the serial console:
CASE A: ONE HID INTERFACE (works correctly)
Code: Select all
#define TUSB_DESC_TOTAL_LEN (TUD_CONFIG_DESC_LEN /* + 1 * TUD_CDC_DESC_LEN */ + 1 * TUD_HID_DESC_LEN)
static const uint8_t configuration_descriptor[] = {
// Configuration number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, 1, 0, TUSB_DESC_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
// CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
// TUD_CDC_DESCRIPTOR(0, 4, 0x81, 8, 0x82, 0x83, 64),
// Interface number, string index, boot protocol, report descriptor len, EP In address, size & polling interval
TUD_HID_DESCRIPTOR(1, 4, false, sizeof(hid_report_descriptor), 0x84, 16, 10),
};
Code: Select all
S: Manufacturer=Airball.aero
S: Product=Knob+CANBus peripheral
S: SerialNumber=123456
C: #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
I: If#= 1 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=usbhid
E: Ad=84(I) Atr=03(Int.) MxPS= 16 Ivl=10ms
Code: Select all
#define TUSB_DESC_TOTAL_LEN (TUD_CONFIG_DESC_LEN + 1 * TUD_CDC_DESC_LEN /* + 1 * TUD_HID_DESC_LEN */)
static const uint8_t configuration_descriptor[] = {
// Configuration number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, 1, 0, TUSB_DESC_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
// CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
TUD_CDC_DESCRIPTOR(0, 4, 0x81, 8, 0x82, 0x83, 64),
// Interface number, string index, boot protocol, report descriptor len, EP In address, size & polling interval
// TUD_HID_DESCRIPTOR(1, 4, false, sizeof(hid_report_descriptor), 0x84, 16, 10),
};
Code: Select all
S: Manufacturer=Airball.aero
S: Product=Knob+CANBus peripheral
S: SerialNumber=123456
C: #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=02 Prot=00 Driver=cdc_acm
E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=16ms
I: If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_acm
E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
E: Ad=83(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
CASE C: ONE HID AND ONE CDC INTERFACE (does not work)
Code: Select all
#define TUSB_DESC_TOTAL_LEN (TUD_CONFIG_DESC_LEN + 1 * TUD_CDC_DESC_LEN + 1 * TUD_HID_DESC_LEN)
static const uint8_t configuration_descriptor[] = {
// Configuration number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, 2, 0, TUSB_DESC_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
// CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
TUD_CDC_DESCRIPTOR(0, 4, 0x81, 8, 0x82, 0x83, 64),
// Interface number, string index, boot protocol, report descriptor len, EP In address, size & polling interval
TUD_HID_DESCRIPTOR(1, 4, false, sizeof(hid_report_descriptor), 0x84, 16, 10),
};
Code: Select all
S: Manufacturer=Airball.aero
S: Product=Knob+CANBus peripheral
S: SerialNumber=123456
C: #Ifs= 0 Cfg#= 0 Atr= MxPwr=
I: If#= 0 Alt= 0 #EPs= 0 Cls=(none)() Sub= Prot= Driver=
Code: Select all
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x2b (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3820,len:0x1718
load:0x403c9700,len:0x4
load:0x403c9704,len:0xc20
load:0x403cc700,len:0x2f20
entry 0x403c9910
I (27) boot: ESP-IDF v5.2-dev-2164-g3befd5fff7 2nd stage bootloader
I (27) boot: compile time Jan 17 2024 21:01:07
I (28) boot: Multicore bootloader
I (32) boot: chip revision: v0.1
I (36) boot.esp32s3: Boot SPI Speed : 80MHz
I (40) boot.esp32s3: SPI Mode : DIO
I (45) boot.esp32s3: SPI Flash Size : 2MB
I (50) boot: Enabling RNG early entropy source...
I (55) boot: Partition Table:
I (59) boot: ## Label Usage Type ST Offset Length
I (66) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (74) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (81) boot: 2 factory factory app 00 00 00010000 00100000
I (88) boot: End of partition table
I (93) esp_image: segment 0: paddr=00010020 vaddr=3c030020 size=0c770h ( 51056) map
I (110) esp_image: segment 1: paddr=0001c798 vaddr=3fc91f00 size=02948h ( 10568) load
I (113) esp_image: segment 2: paddr=0001f0e8 vaddr=40374000 size=00f30h ( 3888) load
I (119) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=20074h (131188) map
I (150) esp_image: segment 4: paddr=0004009c vaddr=40374f30 size=0cf0ch ( 53004) load
I (168) boot: Loaded app from partition at offset 0x10000
I (168) boot: Disabling RNG early entropy source...
I (179) cpu_start: Multicore app
I (180) cpu_start: Pro cpu up.
I (180) cpu_start: Starting app cpu, entry point is 0x40375238
I (0) cpu_start: App cpu up.
I (198) cpu_start: Pro cpu start user code
I (198) cpu_start: cpu freq: 160000000 Hz
I (203) cpu_start: Application information:
I (203) cpu_start: Project name: knob
I (206) cpu_start: App version: 1
I (210) cpu_start: Compile time: Jan 17 2024 21:01:23
I (217) cpu_start: ELF file SHA256: 3a5b1a879...
I (222) cpu_start: ESP-IDF: v5.2-dev-2164-g3befd5fff7
I (228) cpu_start: Min chip rev: v0.0
I (233) cpu_start: Max chip rev: v0.99
I (238) cpu_start: Chip rev: v0.1
I (243) heap_init: Initializing. RAM available for dynamic allocation:
I (250) heap_init: At 3FC95B90 len 00053B80 (334 KiB): DRAM
I (256) heap_init: At 3FCE9710 len 00005724 (21 KiB): STACK/DRAM
I (263) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (269) heap_init: At 600FE010 len 00001FD8 (7 KiB): RTCRAM
I (276) spi_flash: detected chip: generic
I (280) spi_flash: flash io: dio
W (284) spi_flash: Detected size(8192k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (297) sleep: Configure to isolate all GPIO pins in sleep state
I (304) sleep: Enable automatic switching of GPIO sleep configuration
I (311) app_start: Starting scheduler on CPU0
I (316) app_start: Starting scheduler on CPU1
I (316) main_task: Started on CPU0
I (326) main_task: Calling app_main()
W (326) TinyUSB: The device's device descriptor is not provided by user, using default.
I (386) tusb_desc:
┌─────────────────────────────────┐
│ USB Device Descriptor Summary │
├───────────────────┬─────────────┤
│bDeviceClass │ 239 │
├───────────────────┼─────────────┤
│bDeviceSubClass │ 2 │
├───────────────────┼─────────────┤
│bDeviceProtocol │ 1 │
├───────────────────┼─────────────┤
│bMaxPacketSize0 │ 64 │
├───────────────────┼─────────────┤
│idVendor │ 0x303a │
├───────────────────┼─────────────┤
│idProduct │ 0x4005 │
├───────────────────┼─────────────┤
│bcdDevice │ 0x100 │
├───────────────────┼─────────────┤
│iManufacturer │ 0x1 │
├───────────────────┼─────────────┤
│iProduct │ 0x2 │
├───────────────────┼─────────────┤
│iSerialNumber │ 0x3 │
├───────────────────┼─────────────┤
│bNumConfigurations │ 0x1 │
└───────────────────┴─────────────┘
I (546) TinyUSB: TinyUSB Driver installed
I (546) knob: Sending Keyboard report
I (606) main_task: Returned from app_main()
Who is online
Users browsing this forum: Bing [Bot] and 97 guests