espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.55k stars 7.27k forks source link

USB HID Host - Some USB devices not detected on boot, working when attached afterwards (IDFGH-13321) #14244

Closed mrweaver closed 2 months ago

mrweaver commented 2 months ago

Answers checklist.

IDF version.

v5.2.2

Espressif SoC revision.

ESP32-S3 (QFN56) (revision v0.1)

Operating System used.

Windows

How did you build your project?

Command line with CMake

If you are using Windows, please specify command line type.

PowerShell

Development Kit.

Custom board

Power Supply used.

USB

What is the expected behavior?

Run hid_host_example.c and have the USB HID remote (G20s Pro) automatically detected and functional on boot.

What is the actual behavior?

Scenario 1 - Logitech Mouse [Success]

When a Logitech wireless mouse (MX Anywhere 2) is plugged into the USB port, then the example is run, the device is correctly detected immediately and inputs from the device are received as expected.

Scenario 2 - USB Remote [Failure]

When the same is performed as above, expect instead of the Logitech device, the G20s Pro remote ( Chinese air mouse), the device will not be detected on the initial boot. If the device is unplugged, then plugged back in, the device is correctly detected and functions as expected (see logs)

Not sure if this is expected for the device in question based on the descriptors, or if this is some unwanted behaviour. I have tried adding various delays in the code, but none seem to have any affect. @roma-jam - I was wondering if you'd have any input on this.

Steps to reproduce.

  1. Insert USB device a. - Logitech b. Scenario 2 - USB Remote
  2. Using VSCode, run unaltered example - hid_host_example.c
  3. Observe program outputs a. Scenario 1 - Works b. Scenario 2 - Fails

Debug Logs.

## Scenario 1 - Logitech Mouse [Success]
### `DEBUG` level output

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:0x3fce3810,len:0x178c
load:0x403c9700,len:0x4
load:0x403c9704,len:0xcbc
load:0x403cc700,len:0x2d9c
entry 0x403c9914
I (27) boot: ESP-IDF v5.2.2 2nd stage bootloader
I (27) boot: compile time Jul 25 2024 13:19:41
I (27) boot: Multicore bootloader
I (30) boot: chip revision: v0.1
I (34) boot.esp32s3: Boot SPI Speed : 80MHz
I (39) boot.esp32s3: SPI Mode       : DIO
I (43) boot.esp32s3: SPI Flash Size : 2MB
I (48) boot: Enabling RNG early entropy source...
I (53) boot: Partition Table:
I (57) boot: ## Label            Usage          Type ST Offset   Length
I (64) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (72) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (79) boot:  2 factory          factory app      00 00 00010000 00100000
I (87) boot: End of partition table
I (91) esp_image: segment 0: paddr=00010020 vaddr=3c030020 size=0cf4ch ( 53068) map
I (109) esp_image: segment 1: paddr=0001cf74 vaddr=3fc92900 size=027c4h ( 10180) load
I (111) esp_image: segment 2: paddr=0001f740 vaddr=40374000 size=008d8h (  2264) load
I (117) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=22e34h (142900) map
I (150) esp_image: segment 4: paddr=00042e5c vaddr=403748d8 size=0dfe0h ( 57312) load
I (169) boot: Loaded app from partition at offset 0x10000
I (169) boot: Disabling RNG early entropy source...
I (181) cpu_start: Multicore app
D (181) cpu_start: Pro cpu up
D (181) cpu_start: Starting app cpu, entry point is 0x40375214
0x40375214: call_start_cpu1 at C:/Users/michael/esp/v5.2.2/esp-idf/components/esp_system/port/cpu_start.c:183

D (0) cpu_start: App cpu up
D (191) clk: RTC_SLOW_CLK calibration value: 3652749
I (202) cpu_start: Pro cpu start user code
I (202) cpu_start: cpu freq: 160000000 Hz
I (202) cpu_start: Application information:
I (205) cpu_start: Project name:     hid
I (210) cpu_start: App version:      1
I (214) cpu_start: Compile time:     Jul 25 2024 13:19:36
I (220) cpu_start: ELF file SHA256:  39676eace...
I (226) cpu_start: ESP-IDF:          v5.2.2
I (230) cpu_start: Min chip rev:     v0.0
I (235) cpu_start: Max chip rev:     v0.99
I (240) cpu_start: Chip rev:         v0.1
D (245) memory_layout: Checking 6 reserved memory ranges:
D (250) memory_layout: Reserved memory range 0x3fc84000 - 0x3fc92900
D (257) memory_layout: Reserved memory range 0x3fc92900 - 0x3fc95938
D (263) memory_layout: Reserved memory range 0x3fceee34 - 0x3fcf0000
D (269) memory_layout: Reserved memory range 0x40374000 - 0x40382900
0x40374000: _WindowOverflow4 at C:/Users/michael/esp/v5.2.2/esp-idf/components/xtensa/xtensa_vectors.S:2027

D (276) memory_layout: Reserved memory range 0x600fe000 - 0x600fe010
D (282) memory_layout: Reserved memory range 0x600fffe8 - 0x60100000
D (289) memory_layout: Building list of available memory regions:
D (295) memory_layout: Available memory region 0x3fc95938 - 0x3fca0000
D (301) memory_layout: Available memory region 0x3fca0000 - 0x3fcb0000
D (308) memory_layout: Available memory region 0x3fcb0000 - 0x3fcc0000
D (315) memory_layout: Available memory region 0x3fcc0000 - 0x3fcd0000
D (321) memory_layout: Available memory region 0x3fcd0000 - 0x3fce0000
D (328) memory_layout: Available memory region 0x3fce0000 - 0x3fce9710
D (334) memory_layout: Available memory region 0x3fce9710 - 0x3fceee34
D (341) memory_layout: Available memory region 0x3fcf0000 - 0x3fcf8000
D (348) memory_layout: Available memory region 0x600fe010 - 0x600fffe8
I (354) heap_init: Initializing. RAM available for dynamic allocation:
D (362) heap_init: New heap initialised at 0x3fc95938
I (367) heap_init: At 3FC95938 len 00053DD8 (335 KiB): RAM
I (373) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
D (379) heap_init: New heap initialised at 0x3fcf0000
I (384) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
D (390) heap_init: New heap initialised at 0x600fe010
I (395) heap_init: At 600FE010 len 00001FD8 (7 KiB): RTCRAM
D (402) intr_alloc: Connected src 39 to int 2 (cpu 0)
D (407) spi_flash: trying chip: issi
D (410) spi_flash: trying chip: gd
I (414) spi_flash: detected chip: gd
I (418) spi_flash: flash io: dio
W (422) spi_flash: Detected size(16384k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
D (435) cpu_start: calling init function: 0x42011450
0x42011450: esp_ipc_init at C:/Users/michael/esp/v5.2.2/esp-idf/components/esp_system/esp_ipc.c:114

D (440) cpu_start: calling init function: 0x40379ac4
0x40379ac4: enable_timer_group0_for_calibration at C:/Users/michael/esp/v5.2.2/esp-idf/components/esp_hw_support/port/esp32s3/rtc_time.c:199

D (445) cpu_start: calling init function: 0x420018a0
0x420018a0: esp_app_format_init_elf_sha256 at C:/Users/michael/esp/v5.2.2/esp-idf/components/esp_app_format/esp_app_desc.c:68

D (450) cpu_start: calling init function: 0x4200eee8 on core: 0
0x4200eee8: __esp_system_init_fn_esp_timer_startup_init at C:/Users/michael/esp/v5.2.2/esp-idf/components/esp_timer/src/esp_timer.c:578

D (456) intr_alloc: Connected src 59 to int 3 (cpu 0)
D (461) cpu_start: calling init function: 0x420042f4 on core: 0
0x420042f4: __esp_system_init_fn_esp_sleep_startup_init at C:/Users/michael/esp/v5.2.2/esp-idf/components/esp_hw_support/sleep_gpio.c:189

I (467) sleep: Configure to isolate all GPIO pins in sleep state
I (474) sleep: Enable automatic switching of GPIO sleep configuration
D (481) cpu_start: calling init function: 0x42002844 on core: 0
0x42002844: __esp_system_init_fn_init_components0 at C:/Users/michael/esp/v5.2.2/esp-idf/components/esp_system/startup.c:493

D (487) intr_alloc: Connected src 79 to int 9 (cpu 0)
D (492) app_start: Starting scheduler on CPU0
D (496) intr_alloc: Connected src 57 to int 12 (cpu 0)
D(4;6) In(r_6l oci _onnected src 8ontC int 2m
cpu 1)
D (506) app_start: Starting scheduler on CPU1
D (506) intr_alloc: Connected src 58 to int 3 (cpu 1)
D (506) heap_init: New heap initialised at 0x3fce9710
D (516) intr_alloc: Connected src 52 to int 13 (cpu 0)
I (526) main_task: Calling app_main()
I (526) example: HID Host example
I (526) gpio: GPIO[0]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:2
D (536) intr_alloc: Connected src 16 to int 17 (cpu 0)
D (546) intr_alloc: Connected src 38 to int 18 (cpu 0)
D (576) hid-host: USB HID handling start
D (576) hid-host: USB HID handling
I (576) example: Waiting for HID Device to be connected
D (886) HUB: Root port reset
D (886) HUB: Stage done: START
D (886) HUB: Stage done: GET_SHORT_DEV_DESC
D (886) HUB: Stage done: CHECK_SHORT_DEV_DESC
D (946) HUB: Stage done: SECOND_RESET
D (946) HUB: Stage done: SET_ADDR
D (946) HUB: Stage done: CHECK_ADDR
D (956) HUB: Stage done: SET_ADDR_RECOVERY
D (956) HUB: Stage done: GET_FULL_DEV_DESC
D (956) HUB: Stage done: CHECK_FULL_DEV_DESC
D (956) HUB: Stage done: GET_SHORT_CONFIG_DESC
D (956) HUB: Stage done: CHECK_SHORT_CONFIG_DESC
D (966) HUB: Stage done: GET_FULL_CONFIG_DESC
D (966) HUB: Stage done: CHECK_FULL_CONFIG_DESC
D (966) HUB: Stage done: SET_CONFIG
D (976) HUB: Stage done: CHECK_CONFIG
D (976) HUB: Stage done: GET_SHORT_LANGID_TABLE
D (986) HUB: Stage done: CHECK_SHORT_LANGID_TABLE
D (986) HUB: Stage done: GET_FULL_LANGID_TABLE
D (996) HUB: Stage done: CHECK_FULL_LANGID_TABLE
D (996) HUB: Stage done: GET_SHORT_MANU_STR_DESC
D (996) HUB: Stage done: CHECK_SHORT_MANU_STR_DESC
D (1006) HUB: Stage done: GET_FULL_MANU_STR_DESC
D (1006) HUB: Stage done: CHECK_FULL_MANU_STR_DESC
D (1016) HUB: Stage done: GET_SHORT_PROD_STR_DESC
D (1016) HUB: Stage done: CHECK_SHORT_PROD_STR_DESC
D (1026) HUB: Stage done: GET_FULL_PROD_STR_DESC
D (1026) HUB: Stage done: CHECK_FULL_PROD_STR_DESC
D (1036) HUB: Stage done: CLEANUP
D (1036) USBH: Processing actions 0x100
D (1036) USBH: New device 1
D (1046) hid-host: Found HID, bInterfaceNumber=0
D (1046) hid-host: Found HID, bInterfaceNumber=1
D (1056) hid-host: Found HID, bInterfaceNumber=2
D (1056) hid-host: USB HID handling
I (1056) example: HID Device, protocol 'KEYBOARD' CONNECTED
D (1066) USBH: Processing actions 0x4
D (1066) USBH: Default pipe device 1
D (1076) hid-host: USB HID handling
D (1076) hid-host: 0x3fc9d41c   21 0b 00 00 00 00 00 00                           |!.......|
D (1086) USBH: Processing actions 0x4
D (1086) USBH: Default pipe device 1
D (1096) hid-host: USB HID handling
D (1096) hid-host: 0x3fc9d41c   21 0a 00 00 00 00 00 00                           |!.......|
I (1106) example: HID Device, protocol 'MOUSE' CONNECTED
D (1116) USBH: Processing actions 0x4
D (1116) USBH: Default pipe device 1
D (1116) hid-host: USB HID handling
D (1126) hid-host: 0x3fc9d41c   21 0b 00 00 01 00 00 00                           |!.......|
I (1126) example: HID Device, protocol 'NONE' CONNECTED

Scenario 2 - USB Remote [Failure]

DEBUG level output

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:0x3fce3810,len:0x178c
load:0x403c9700,len:0x4
load:0x403c9704,len:0xcbc
load:0x403cc700,len:0x2d9c
entry 0x403c9914
I (27) boot: ESP-IDF v5.2.2 2nd stage bootloader
I (27) boot: compile time Jul 25 2024 13:19:41
I (27) boot: Multicore bootloader
I (30) boot: chip revision: v0.1
I (34) boot.esp32s3: Boot SPI Speed : 80MHz
I (39) boot.esp32s3: SPI Mode       : DIO
I (43) boot.esp32s3: SPI Flash Size : 2MB
I (48) boot: Enabling RNG early entropy source...
I (53) boot: Partition Table:
I (57) boot: ## Label            Usage          Type ST Offset   Length
I (64) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (72) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (79) boot:  2 factory          factory app      00 00 00010000 00100000
I (87) boot: End of partition table
I (91) esp_image: segment 0: paddr=00010020 vaddr=3c030020 size=0cf4ch ( 53068) map
I (109) esp_image: segment 1: paddr=0001cf74 vaddr=3fc92900 size=027c4h ( 10180) load
I (111) esp_image: segment 2: paddr=0001f740 vaddr=40374000 size=008d8h (  2264) load
I (117) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=22e34h (142900) map
I (150) esp_image: segment 4: paddr=00042e5c vaddr=403748d8 size=0dfe0h ( 57312) load
I (169) boot: Loaded app from partition at offset 0x10000
I (169) boot: Disabling RNG early entropy source...
I (181) cpu_start: Multicore app
D (181) cpu_start: Pro cpu up
D (181) cpu_start: Starting app cpu, entry point is 0x40375214
0x40375214: call_start_cpu1 at C:/Users/michael/esp/v5.2.2/esp-idf/components/esp_system/port/cpu_start.c:183

D (0) cpu_start: App cpu up
D (191) clk: RTC_SLOW_CLK calibration value: 3654080
I (202) cpu_start: Pro cpu start user code
I (202) cpu_start: cpu freq: 160000000 Hz
I (202) cpu_start: Application information:
I (205) cpu_start: Project name:     hid
I (210) cpu_start: App version:      1
I (214) cpu_start: Compile time:     Jul 25 2024 13:19:36
I (220) cpu_start: ELF file SHA256:  39676eace...
I (226) cpu_start: ESP-IDF:          v5.2.2
I (230) cpu_start: Min chip rev:     v0.0
I (235) cpu_start: Max chip rev:     v0.99 
I (240) cpu_start: Chip rev:         v0.1
D (245) memory_layout: Checking 6 reserved memory ranges:
D (250) memory_layout: Reserved memory range 0x3fc84000 - 0x3fc92900
D (257) memory_layout: Reserved memory range 0x3fc92900 - 0x3fc95938
D (263) memory_layout: Reserved memory range 0x3fceee34 - 0x3fcf0000
D (269) memory_layout: Reserved memory range 0x40374000 - 0x40382900
0x40374000: _WindowOverflow4 at C:/Users/michael/esp/v5.2.2/esp-idf/components/xtensa/xtensa_vectors.S:2027

D (276) memory_layout: Reserved memory range 0x600fe000 - 0x600fe010
D (282) memory_layout: Reserved memory range 0x600fffe8 - 0x60100000
D (289) memory_layout: Building list of available memory regions:
D (295) memory_layout: Available memory region 0x3fc95938 - 0x3fca0000
D (301) memory_layout: Available memory region 0x3fca0000 - 0x3fcb0000
D (308) memory_layout: Available memory region 0x3fcb0000 - 0x3fcc0000
D (315) memory_layout: Available memory region 0x3fcc0000 - 0x3fcd0000
D (321) memory_layout: Available memory region 0x3fcd0000 - 0x3fce0000
D (328) memory_layout: Available memory region 0x3fce0000 - 0x3fce9710
D (334) memory_layout: Available memory region 0x3fce9710 - 0x3fceee34
D (341) memory_layout: Available memory region 0x3fcf0000 - 0x3fcf8000
D (348) memory_layout: Available memory region 0x600fe010 - 0x600fffe8
I (354) heap_init: Initializing. RAM available for dynamic allocation:
D (362) heap_init: New heap initialised at 0x3fc95938
I (367) heap_init: At 3FC95938 len 00053DD8 (335 KiB): RAM
I (373) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
D (379) heap_init: New heap initialised at 0x3fcf0000
I (384) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
D (390) heap_init: New heap initialised at 0x600fe010
I (395) heap_init: At 600FE010 len 00001FD8 (7 KiB): RTCRAM
D (402) intr_alloc: Connected src 39 to int 2 (cpu 0)
D (407) spi_flash: trying chip: issi
D (410) spi_flash: trying chip: gd
I (414) spi_flash: detected chip: gd
I (418) spi_flash: flash io: dio
W (422) spi_flash: Detected size(16384k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
D (435) cpu_start: calling init function: 0x42011450
0x42011450: esp_ipc_init at C:/Users/michael/esp/v5.2.2/esp-idf/components/esp_system/esp_ipc.c:114

D (440) cpu_start: calling init function: 0x40379ac4
0x40379ac4: enable_timer_group0_for_calibration at C:/Users/michael/esp/v5.2.2/esp-idf/components/esp_hw_support/port/esp32s3/rtc_time.c:199

D (445) cpu_start: calling init function: 0x420018a0
0x420018a0: esp_app_format_init_elf_sha256 at C:/Users/michael/esp/v5.2.2/esp-idf/components/esp_app_format/esp_app_desc.c:68

D (450) cpu_start: calling init function: 0x4200eee8 on core: 0
0x4200eee8: __esp_system_init_fn_esp_timer_startup_init at C:/Users/michael/esp/v5.2.2/esp-idf/components/esp_timer/src/esp_timer.c:578

D (456) intr_alloc: Connected src 59 to int 3 (cpu 0)
D (461) cpu_start: calling init function: 0x420042f4 on core: 0
0x420042f4: __esp_system_init_fn_esp_sleep_startup_init at C:/Users/michael/esp/v5.2.2/esp-idf/components/esp_hw_support/sleep_gpio.c:189

I (467) sleep: Configure to isolate all GPIO pins in sleep state
I (474) sleep: Enable automatic switching of GPIO sleep configuration
D (481) cpu_start: calling init function: 0x42002844 on core: 0
0x42002844: __esp_system_init_fn_init_components0 at C:/Users/michael/esp/v5.2.2/esp-idf/components/esp_system/startup.c:493

D (487) intr_alloc: Connected src 79 to int 9 (cpu 0)
D (492) app_start: Starting scheduler on CPU0
D (496) intr_alloc: Connected src 57 to int 12 (cpu 0)
D(4;6) In(r_6l oci _onnected src 8ontC int 2m
cpu 1)
D (506) app_start: Starting scheduler on CPU1
D (506) intr_alloc: Connected src 58 to int 3 (cpu 1)
D (506) heap_init: New heap initialised at 0x3fce9710
D (516) intr_alloc: Connected src 52 to int 13 (cpu 0)
I (526) main_task: Calling app_main()
I (526) example: HID Host example
I (526) gpio: GPIO[0]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:2
D (536) intr_alloc: Connected src 16 to int 17 (cpu 0)
D (546) intr_alloc: Connected src 38 to int 18 (cpu 0)
D (576) hid-host: USB HID handling start
D (576) hid-host: USB HID handling
I (576) example: Waiting for HID Device to be connected
D (886) HUB: Root port reset
D (886) HUB: Stage done: START
D (886) HUB: Stage done: GET_SHORT_DEV_DESC

================= Device unplugged here =================

E (1127751) HUB: Bad transfer status 1: CHECK_SHORT_DEV_DESC
E (1127751) HUB: Stage failed: CHECK_SHORT_DEV_DESC
D (1127751) HUB: Stage done: CLEANUP_FAILED
D (1127791) HUB: Recovering root port

================= Device plugged back in here =================

D (1148101) HUB: Root port reset
D (1148101) HUB: Stage done: START
D (1148101) HUB: Stage done: GET_SHORT_DEV_DESC
D (1148101) HUB: Stage done: CHECK_SHORT_DEV_DESC
D (1148161) HUB: Stage done: SECOND_RESET
D (1148161) HUB: Stage done: SET_ADDR
D (1148161) HUB: Stage done: CHECK_ADDR
D (1148171) HUB: Stage done: SET_ADDR_RECOVERY
D (1148171) HUB: Stage done: GET_FULL_DEV_DESC
D (1148171) HUB: Stage done: CHECK_FULL_DEV_DESC
D (1148171) HUB: Stage done: GET_SHORT_CONFIG_DESC
D (1148171) HUB: Stage done: CHECK_SHORT_CONFIG_DESC
D (1148181) HUB: Stage done: GET_FULL_CONFIG_DESC
D (1148181) HUB: Stage done: CHECK_FULL_CONFIG_DESC
D (1148191) HUB: Stage done: SET_CONFIG
D (1148191) HUB: Stage done: CHECK_CONFIG
D (1148201) HUB: Stage done: GET_SHORT_LANGID_TABLE
D (1148201) HUB: Stage done: CHECK_SHORT_LANGID_TABLE
D (1148211) HUB: Stage done: GET_FULL_LANGID_TABLE
D (1148211) HUB: Stage done: CHECK_FULL_LANGID_TABLE
D (1148221) HUB: Stage done: GET_SHORT_MANU_STR_DESC
D (1148221) HUB: Stage done: CHECK_SHORT_MANU_STR_DESC
D (1148231) HUB: Stage done: GET_FULL_MANU_STR_DESC
D (1148231) HUB: Stage done: CHECK_FULL_MANU_STR_DESC
D (1148241) HUB: Stage done: GET_SHORT_PROD_STR_DESC
D (1148241) HUB: Stage done: CHECK_SHORT_PROD_STR_DESC
D (1148251) HUB: Stage done: GET_FULL_PROD_STR_DESC
D (1148251) HUB: Stage done: CHECK_FULL_PROD_STR_DESC
D (1148261) HUB: Stage done: CLEANUP
D (1148261) USBH: Processing actions 0x100
D (1148261) USBH: New device 1
D (1148271) hid-host: Found HID, bInterfaceNumber=2
D (1148271) hid-host: Found HID, bInterfaceNumber=3
D (1148281) hid-host: USB HID handling
I (1148281) example: HID Device, protocol 'KEYBOARD' CONNECTED
I (1148291) example: HID Device, protocol 'MOUSE' CONNECTED

USB Remote - Device Descriptor using usb_host_lib example

I (335) CLASS: Registering Client
I (21305) CLASS: Opening device at address 1
I (21305) CLASS: Getting device information
I (21305) CLASS:        Full speed
I (21305) CLASS:        bConfigurationValue 1
I (21315) CLASS: Getting device descriptor
*** Device descriptor ***
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0x0
bDeviceSubClass 0x0
bDeviceProtocol 0x0
bMaxPacketSize0 64
idVendor 0xc40
idProduct 0x7a1c
bcdDevice 2.00
iManufacturer 1
iProduct 2
iSerialNumber 0
bNumConfigurations 1
I (21335) CLASS: Getting config descriptor
*** Configuration descriptor ***
bLength 9
bDescriptorType 2
wTotalLength 159
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
bMaxPower 100mA
        *** Interface descriptor ***
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 0
        bAlternateSetting 0
        bNumEndpoints 0
        bInterfaceClass 0x1
        bInterfaceSubClass 0x1
        bInterfaceProtocol 0x0
        iInterface 0
        *** Interface descriptor ***
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 1
        bAlternateSetting 0
        bNumEndpoints 0
        bInterfaceClass 0x1
        bInterfaceSubClass 0x2
        bInterfaceProtocol 0x0
        iInterface 0
        *** Interface descriptor ***
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 1
        bAlternateSetting 1
        bNumEndpoints 1
        bInterfaceClass 0x1
        bInterfaceSubClass 0x2
        bInterfaceProtocol 0x0
        iInterface 0
                *** Endpoint descriptor ***
                bLength 9
                bDescriptorType 5
                bEndpointAddress 0x81   EP 1 IN
                bmAttributes 0x5        ISOC
                wMaxPacketSize 32
                bInterval 1
        *** Interface descriptor ***
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 2
        bAlternateSetting 0
        bNumEndpoints 1
        bInterfaceClass 0x3
        bInterfaceSubClass 0x0
        bInterfaceProtocol 0x1
        iInterface 0
                *** Endpoint descriptor ***
                bLength 7
                bDescriptorType 5
                bEndpointAddress 0x83   EP 3 IN
                bmAttributes 0x3        INT
                wMaxPacketSize 16
                bInterval 10
        *** Interface descriptor ***
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 3
        bAlternateSetting 0
        bNumEndpoints 1
        bInterfaceClass 0x3
        bInterfaceSubClass 0x0
        bInterfaceProtocol 0x2
        iInterface 0
                *** Endpoint descriptor ***
                bLength 7
                bDescriptorType 5
                bEndpointAddress 0x82   EP 2 IN
                bmAttributes 0x3        INT
                wMaxPacketSize 16
                bInterval 10
I (21485) CLASS: Getting Manufacturer string descriptor
SG.Ltd
I (21485) CLASS: Getting Product string descriptor
SG Control Mic


### More Information.

_No response_
peter-marcisovsky commented 2 months ago

Hi @mrweaver thank you for reporting the issue and for providing all the logs. We will have a look and let you know.

mrweaver commented 2 months ago

Hi @peter-marcisovsky, thanks very much for that, I really appreciate it. Please let me know if you need more details.

roma-jam commented 2 months ago

Hi @mrweaver ,

Thanks for the detailed logs.

I have tried adding various delays in the code

There are three configurable parameters available with the menuconfig. More details here:

Have you tried to change them? Could you increase the RESET_HOLD and RESET_RECOVERY for, lets say, 500 ms (default values are 30 ms) and try to connect the device again?

The problem should be the same with hid example and usb_host_lib, so you can use the last one to eliminate the hid logic from verification to simplify the output.

Do you have any option to use USB analyzer to capture the transfer log with the device you are trying to use?

mrweaver commented 2 months ago

Hey @roma-jam,

Thanks for getting back to me. I did see those parameters, but for some reason I (rather foolishly, in hindsight) assumed that the device should follow the standard USB timings and so I didn't change them.

Anyway, I recompiled it with some different values and found that for the case of this particular device, configuring the parameter RESET_RECOVERY to 80ms+ (while leaving the others as default) seems to do the trick and it resolves the issue - that is the device is discovered on boot.

Thanks so much for your help, I really appreciate it.

Cheers, Michael.