Skip to content

BUG: USB icon stuck after cable disconnect on boards without VBUS detection #3374

Description

@paoloantinori

Description

After flashing via USB and unplugging the cable, the display continues showing the USB icon instead of switching to the BT icon. The endpoint never switches to BLE.

Root Cause

Some nRF52840 boards (e.g. Corne-ish Zen) have no VBUS detection configured. When the USB cable is pulled, the nRF52840 USB peripheral detects bus idle (no SOF packets) and reports USB_DC_SUSPEND, but ZMK maps this to ZMK_USB_CONN_HID (still "connected") in app/src/usb.c. Without VBUS detection, the chip cannot distinguish "cable unplugged" from "host suspended the bus."

The status flow on cable unplug is:

USB_DC_CONFIGURED -> USB_DC_SUSPEND   (cable pulled)

While for a legitimate host suspend (e.g. closing a laptop lid):

USB_DC_CONFIGURED -> USB_DC_SUSPEND -> USB_DC_RESUME   (host wakes)

Both cases look identical to the USB peripheral without VBUS detection.

Related Issues

This is related to #841 (USB power-only cable detected as host), which was fixed by PR #2458. That fix addressed the case where a power bank is plugged in (no data), while this issue covers the case where the cable is removed entirely.

Environment

  • Board: Corne-ish Zen (nRF52840)
  • Branch: main
  • Zephyr: v4.1.0+zmk-fixes

Workaround

A configurable suspend timeout can treat prolonged USB_DC_SUSPEND (e.g. >2 seconds without USB_DC_RESUME) as a disconnect. This is a software-only workaround for boards that lack VBUS detection hardware.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions