qmk/qmk_firmware

[Bug] USB Initialization Race Condition

Open

#21.678 aperta il 2 ago 2023

Vedi su GitHub
 (3 commenti) (0 reazioni) (0 assegnatari)C (43.867 fork)batch import
bughelp wanted

Metriche repository

Star
 (20.368 star)
Metriche merge PR
 (Merge medio 20g 9h) (27 PR mergiate in 30 g)

Descrizione

Describe the Bug

I have been using a custom split keyboard with Elite-C v4 (ATMega32U4) microcontrollers that communicate over serial using a USB-C cable.

With the latest QMK Firmware, the keyboard functions after flashing, but stops working after unplugging it from the computer and then plugging it back in.

Wireshark showed "GET DESCRIPTOR Response" failing with "Broken pipe (-EPIPE) (-32)" after the host sent a "GET DESCRIPTOR Request DEVICE" message.

I found that adding at least a 16ms delay to the USB_Init function in the LUFA USB drivers resolved the issue.

It seems as if QMK isn't finished setting up the device descriptor in memory by the time it is used in the get_usb_descriptor function of tmk_core, but I can't confirm it because I don't have a serial to usb adapter.

Keyboard Used

Custom Split Keyboard

Link to product page (if applicable)

No response

Operating System

Debian GNU/Linux 12 (bookworm)

qmk doctor Output

Ψ QMK Doctor is checking your environment.
Ψ CLI version: 1.1.2
Ψ QMK home: /home/user/qmk_firmware
Ψ Detected Linux (Debian GNU/Linux 12 (bookworm)).
Ψ Git branch: master
Ψ Repo version: 0.21.6
⚠ Git has unstashed/uncommitted changes.
Ψ - Latest master: 2023-07-30 00:22:39 -0400 (14e14e9ab8) -- Correct "less than" to "up to" in squeezing_avr?id=layers (#21639)
Ψ - Latest upstream/master: 2023-08-02 11:05:00 -0600 (34a2f14274) -- [Keyboard] Add Bento Box macropad (#20521)
Ψ - Latest upstream/develop: None
Ψ - Common ancestor with upstream/master: 2023-07-30 00:22:39 -0400 (14e14e9ab8) -- Correct "less than" to "up to" in squeezing_avr?id=layers (#21639)
Ψ - Common ancestor with upstream/develop: None
Ψ CLI installed in virtualenv.
Ψ All dependencies are installed.
Ψ Found arm-none-eabi-gcc version 12.2.1
Ψ Found avr-gcc version 5.4.0
Ψ Found avrdude version 7.1
Ψ Found dfu-programmer version 0.6.1
Ψ Found dfu-util version 0.11
Ψ Submodules are up to date.
Ψ Submodule status:
Ψ - lib/chibios: 2023-04-15 13:48:04 +0000 --  (11edb1610)
Ψ - lib/chibios-contrib: 2023-01-11 16:42:27 +0100 --  (a224be15)
Ψ - lib/googletest: 2021-06-11 06:37:43 -0700 --  (e2239ee6)
Ψ - lib/lufa: 2022-08-26 12:09:55 +1000 --  (549b97320)
Ψ - lib/vusb: 2022-06-13 09:18:17 +1000 --  (819dbc1)
Ψ - lib/printf: 2022-06-29 23:59:58 +0300 --  (c2e3b4e)
Ψ - lib/pico-sdk: 2023-02-12 20:19:37 +0100 --  (a3398d8)
Ψ - lib/lvgl: 2022-04-11 04:44:53 -0600 --  (e19410f8)
Ψ QMK is ready to go, but minor problems were found

Is AutoHotKey / Karabiner installed

  • AutoHotKey (Windows)
  • Karabiner (macOS)

Other keyboard-related software installed

No response

Additional Context

No response

Guida contributor