Skip to content

usb_descriptors: fix CDC interface numbers and total count in debug build#339

Merged
hrvach merged 1 commit into
hrvach:mainfrom
ibrahim1416:fix/usb-descriptor-debug-build
Jun 26, 2026
Merged

usb_descriptors: fix CDC interface numbers and total count in debug build#339
hrvach merged 1 commit into
hrvach:mainfrom
ibrahim1416:fix/usb-descriptor-debug-build

Conversation

@ibrahim1416

Copy link
Copy Markdown
Contributor

Summary

When DeskHop is built with DH_DEBUG=ON, the configuration descriptor declares CDC at interface number 4 with a total interface count of 3 (normal mode) or 5 (config mode). Both values are inconsistent with the actual descriptor contents:

Mode Actual interfaces Declared bNumInterfaces
Normal HID(0), HID_REL_M(1), CDC ctrl(4), CDC data(5) → 4 3
Config HID(0), HID_REL_M(1), HID_VENDOR(2), MSC(3), CDC ctrl(4), CDC data(5) → 6 5

The non-consecutive interface numbers in normal mode (gaps at 2, 3) caused Windows to reject the device with CM_PROB_FAILED_START (problem code 10). Linux and macOS were more permissive and worked despite the mismatch — so this only manifests on Windows hosts.

Changes

  • Place CDC at the next free interface number for each mode: 2 in normal mode, 4 in config mode (new ITF_NUM_CDC_CONFIG used only in the config-mode descriptor).
  • Correct the declared interface counts: ITF_NUM_TOTAL = 4, ITF_NUM_TOTAL_CONFIG = 6.

No change in behavior when DH_DEBUG=OFF (the entire block is gated on #ifdef DH_DEBUG).

Test plan

  • Build with -DDH_DEBUG=ON and flash to laptop-side Pico. Device enumerates cleanly on Windows 11; USB Serial Device (COMx) appears for the CDC debug port and serial output works.
  • Build with -DDH_DEBUG=OFF: no descriptor changes (block excluded), device behaves identically to upstream.

🤖 Generated with Claude Code

…uild

When built with DH_DEBUG=ON, the configuration descriptor declared CDC at
interface number 4 with a total interface count of 3 (normal mode) or 5
(config mode). Both values were inconsistent with the actual descriptor
contents:

- Normal mode: HID(0) + HID_REL_M(1) + CDC(4, 5) - 4 interfaces, declared 3
- Config mode: HID(0) + HID_REL_M(1) + HID_VENDOR(2) + MSC(3) + CDC(4, 5) -
  6 interfaces, declared 5

The non-consecutive interface numbers in normal mode (0, 1, 4, 5) caused
Windows to reject the device with CM_PROB_FAILED_START (code 10). Linux
and macOS were more permissive and worked despite the mismatch.

Fix by:
- Placing CDC at the next free interface number in each mode: 2 in normal
  mode, 4 in config mode (introducing ITF_NUM_CDC_CONFIG for the latter)
- Correcting the declared interface counts to 4 and 6 respectively

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hrvach hrvach merged commit e7ff232 into hrvach:main Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants